Skip to main content

A lightweight Python wrapper for Ollama AI models.

Project description

EZollama

A simple Python library for interacting with Ollama models via their local API.
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

Import

from ezollama import EzOllama
ez = EzOllama()

Set Model

ez.setmodel("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 Ollama speaking.")

Example

from ezollama import EzOllama

ez = EzOllama()

ez.setmodel("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)

Notes

  • The library checks and quietly starts the Ollama server before each API call.
  • 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.1.5.tar.gz (3.4 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.1.5-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ezollama-0.1.5.tar.gz
Algorithm Hash digest
SHA256 24d5c0bf744c443c72de493d41f2871ca1428a5d12247df362df1816c601a200
MD5 17b6007fc214365b3c918d292679fee1
BLAKE2b-256 b0720df6063e3ecdddd6b7efe3de6c1b086b8042c227ef4a0c098a973a9c803a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ezollama-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8c5f241285b9f7170177a24e7a1a5e2240c8ca7fae55e3e3c3bc0da84e92b5cd
MD5 7ea151c694fa954f495691efa48a253d
BLAKE2b-256 d1612ab1a854ef17af7f607c9256d91b4d030ca02e744b2464c22038d1d40e1d

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