Skip to main content

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
    

Metadata

Release files for llmworker 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llmworker 0.1.7
File Size Uploaded
llmworker-0.1.7.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llmworker 0.1.7
File Interpreter ABI Platform
llmworker-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / llmworker-0.1.7.tar.gz

Download URL llmworker-0.1.7.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a5d67b5424f871f69d57ab685dc9aba59ff6539b8d43383092a38d0726f46ccc
BLAKE2b-256 checksum
How to use checksums
b25ac6948e5147bfa5a7eaa2c7d0f60f1c7c4e7839a6f7d8a5d6eaa691256058
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / llmworker-0.1.7-py3-none-any.whl

Download URL llmworker-0.1.7-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
042b9898c858e34e0067aac10f00a6e4bba4f5ee565b49b2d7b11c7971032bf5
BLAKE2b-256 checksum
How to use checksums
664c6f37eaebf3e18b654e4a0ebe27730a966148355909e5c0350316bb21688f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page