Skip to main content

A lightweight Python toolkit for LLM text and image workflows with Ollama.

Project description

LLMWorker

LLMWorker is a minimal Python library to centralize LLM operations behind reusable workers.

Included Components

  • OllamaClient: low-level client for Ollama HTTP endpoints.
  • TextWorker: helper class for text generation/chat style requests.
  • ImageWorker: helper class for image generation requests.

Basic Usage

from llmworker import OllamaClient, TextWorker, ImageWorker

TEXT_MODEL = "llama3.2:3b"
IMAGE_MODEL = "x/flux2-klein:latest"
OLLAMA_URL = "http://localhost:11434"

client = OllamaClient(base_url=OLLAMA_URL)
text_worker = TextWorker(client, model=TEXT_MODEL)
image_worker = ImageWorker(client, model=IMAGE_MODEL)

answer = text_worker.generate("Explain the origin of universe in one paragraph.")
print(answer)

image_options = {"width": 800, "height": 600}
img_result = image_worker.generate_image("A beach landscape at sunset", **image_options)
with open(f"image.png", "wb") as fw:
    fw.write(img_result)

Important

Note: In some Ollama versions (probably, greater than 0.23.0), Ollama is not working stable with image models. It is adviseable to remove the unstable version of Ollama and install a stable version, in example: 0.23.0 Here are the steps to do it:


a) Uninstall Ollama:

  1. Close the application

    killall Ollama
    
  2. Remove the application and executable

    sudo rm -rf /Applications/Ollama.app
    sudo rm /usr/local/bin/ollama
    
  3. Clear cache and support data

    rm -rf ~/Library/Application\ Support/Ollama
    rm -rf ~/Library/Caches/com.electron.ollama
    rm -rf ~/Library/Saved\ Application\ State/com.electron.ollama.savedState
    
  4. (Optional) Delete downloaded templates

    rm -rf ~/.ollama
    

b) Install Ollama Version 0.23.0:

  1. Download the official Ollama binary

    curl -L -o Ollama-darwin.zip https://github.com/ollama/ollama/releases/download/v0.23.0/Ollama-darwin.zip
    

    (Or download manually from Ollama Releases)

  2. Unzip into the Applications folder

    unzip Ollama-darwin.zip -d /Applications/
    

    (Or unzip and move the app to /Applications manually.)

  3. Delete the zip file to save disk space

    rm Ollama-darwin.zip
    
  4. Create a global symlink for the ollama command

    sudo ln -sf /Applications/Ollama.app/Contents/Resources/ollama /usr/local/bin/ollama
    
  5. Remove macOS quarantine on the app

    xattr -r -d com.apple.quarantine /Applications/Ollama.app
    

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

llmworker-0.1.7.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

llmworker-0.1.7-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file llmworker-0.1.7.tar.gz.

File metadata

  • Download URL: llmworker-0.1.7.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for llmworker-0.1.7.tar.gz
Algorithm Hash digest
SHA256 a5d67b5424f871f69d57ab685dc9aba59ff6539b8d43383092a38d0726f46ccc
MD5 602d479020eb77fbd9dfa1efc6ced1ed
BLAKE2b-256 b25ac6948e5147bfa5a7eaa2c7d0f60f1c7c4e7839a6f7d8a5d6eaa691256058

See more details on using hashes here.

File details

Details for the file llmworker-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: llmworker-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for llmworker-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 042b9898c858e34e0067aac10f00a6e4bba4f5ee565b49b2d7b11c7971032bf5
MD5 ca0b63545164d4e0923861d06309fe71
BLAKE2b-256 664c6f37eaebf3e18b654e4a0ebe27730a966148355909e5c0350316bb21688f

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