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 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.1.1.tar.gz (3.6 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.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ezollama-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 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.1.tar.gz
Algorithm Hash digest
SHA256 45b12eddf8c7cafa9b5ab4b6c0dcc563e37b558c84b66c74c6721b9d143d95c3
MD5 0017450a1a5ea7f77a1f507e18c5bd7d
BLAKE2b-256 5610cba16e5299844b4f6e9eb95079e41d2c2a5f59fe4c609ad6cc196b026669

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ezollama-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98da50c3191a9586ff2322da17c6934d6fa157a86cc6cc7783d9e61f3e4db01e
MD5 a4246cb3e9d468c3b45175d47b91e3c9
BLAKE2b-256 6d4f93d5de135dd448049664c93f6fcb21a269fcc14b19648436e7da3d63187c

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