Skip to main content

A lightweight Python wrapper for Ollama AI models.

Project description

EZollama

Python License PyPI

A simple Python library for interacting with Ollama models via their local API and cloud models through Google, Groq, OpenAI and Anthropic.
Supports model selection, chatting, persistent system prompts, listing models, downloading models, resetting chat history, and text-to-speech.


Installation

  1. Install Ollama:
    Download and install Ollama from https://ollama.com/download.
    The library will prompt to install Ollama if not found.

  2. Python dependencies:
    The library auto-installs pyttsx3 for text-to-speech if missing.


Usage for local

Import

from ezollama import EzOllama
ez = EzOllama()

Set Model

ez.set_model("llama2")

Set Persistent System Prompt

ez.set_system_prompt("You are a helpful assistant.")

Chat

response = ez.chat("Hello!")
print(response)

List Available Models

models = ez.list_models()
print(models)

Pull (Download) a Model

ez.pull_model("llama2")

Reset Chat History

ez.reset_history()

Text-to-Speech

ez.text_to_speech("Hello, this is AI speaking.")

Usage for cloud

Import

from ezollama import EzOllama
ez = EzOllama()

Set mode

ez.set_mode("mode", "api-key") # choosable from groq, google, anthropic and openai

Set model

ez.set_model("model") # for example 'gemini-2.5-flash

Set Persistent System Prompt

ez.set_system_prompt("You are a helpful assistant.")

Example for local

from ezollama import EzOllama

ez = EzOllama()

ez.set_model("llama3.2:3b")
ez.set_system_prompt("You are a friendly assistant.")

while True:
    user_input = input("- ")
    resp = ez.chat(user_input)
    print(resp)
    ez.text_to_speech(resp)

Example for cloud

from ezollama import EzOllama

ez = EzOllama()

ez.set_mode("google" "API-KEY")
ez.set_model("gemini-2.5-flash")
ez.set_system_prompt("You are a friendly assistant.")

while True:
    user_input = input("- ")
    resp = ez.chat(user_input)
    print(resp)

Notes

  • The library checks and quietly starts the Ollama server before each API call.
  • If Ollama is not installed, you will be prompted to install it.
  • If the model does not exist, pull_model will print a message.
  • Text-to-speech uses pyttsx3 and works cross-platform.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ezollama-0.2.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ezollama-0.2.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file ezollama-0.2.1.tar.gz.

File metadata

  • Download URL: ezollama-0.2.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for ezollama-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ba479facf32813d725997b7b1bc6ecbcd6d6e435669b475aa099d6736357bef4
MD5 1fafda4a2df9e5b8b6ab2b0544eda29e
BLAKE2b-256 b66d09b32b41c7d7efbcd17100a48e7b6d35fcef8dda8247c5a7f576b1310ca1

See more details on using hashes here.

File details

Details for the file ezollama-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: ezollama-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for ezollama-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3367ba9ea76a4c7b7f5d678c9a164af2967ea7215ae5c8ce9e56e620ef179dc5
MD5 02ec1109fc72a4ea1552e16b1796d815
BLAKE2b-256 cf845e75e1d3a638f8c22f93795a009a3929267ea0294d7d4408d5410681e4bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page