Skip to main content

A flexible wrapper for LLM providers with caching, async support, and cost tracking

Project description

LLM Wrapper

A flexible wrapper for LLM providers with caching, async support, and cost logging.

Installation

pip install llm-wrapper

Quick Start

from llm_wrapper import OpenAIProvider

# Initialize the provider
provider = OpenAIProvider(model="gpt-4o-mini", api_key="your-api-key")

# Generate a single response
response = provider.generate("What is the capital of France?")

# Generate multiple responses with caching
responses = provider.generate(
    ["What is 2+2?", "What is the weather?"],
    system_prompt="You are a helpful assistant.",
    temperature=0.7
)

# For the second call, you will retrieve responses from cache
responses = provider.generate(
    ["What is 2+2?", "What is the weather?"],
    system_prompt="You are a helpful assistant.",
    temperature=0.7
)

Usage with Local Models

from llm_wrapper import LocalProvider

# Initialize the provider with a local model
provider = LocalProvider(
    model="your-model-name",
    host="your-server-host",
    port=8000
)

# Generate responses
responses = provider.generate(["Your prompt here"])

Testing

# Install local package with test dependencies
uv pip install '.[test]'
# Run tests with output
python -m pytest -s tests

Deploying

hatch build
twine upload dist/*

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

llm_wrapper_yl-0.1.0.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

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

llm_wrapper_yl-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file llm_wrapper_yl-0.1.0.tar.gz.

File metadata

  • Download URL: llm_wrapper_yl-0.1.0.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for llm_wrapper_yl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15aa78a70a5792769c1618cb67d8cd9165d3503793724572c1c5246a1f724910
MD5 8b7dfe676335f8b093e7d58092e711f5
BLAKE2b-256 e0c238fdd5cb720edccbe2d8faa9611ded7b6cd786bab5749c0f5b781fda2d63

See more details on using hashes here.

File details

Details for the file llm_wrapper_yl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llm_wrapper_yl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for llm_wrapper_yl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88d62f39c6d29a330b2e49478b086823006a88835ac9f7f0bd535380b5d1c721
MD5 dd2e8874c659935e0e65e18068ac3d39
BLAKE2b-256 985de738f34ad8e2f0a5b235b2e206ef66e387dbd39d4023ae1ea1ae627ec709

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