A lightweight runtime for LLMHub that delegates to any-llm
Project description
llmhub_runtime
llmhub_runtime is a small Python library that lets you call LLMs by role using a simple YAML config (llmhub.yaml), while delegating all provider-specific logic to any-llm.
It is designed to be:
- Runtime-light – minimal dependencies, no discovery logic.
- Provider-agnostic – supports any provider that
any-llmsupports. - Role-centric – your application code never handles provider/model strings directly.
llmhub_runtime is intended for:
- Application backends (e.g. memory systems, agents, tools).
- The future
llmhubCLI/Web tool, which will generatellmhub.yamland then use this runtime internally.
Installation
pip install llmhub-runtime any-llm-sdk
(Exact package name to be confirmed when publishing.)
Runtime Config: llmhub.yaml
llmhub_runtime reads a generated config file, typically named llmhub.yaml:
project: memory
env: dev
providers:
openai:
env_key: OPENAI_API_KEY
anthropic:
env_key: ANTHROPIC_API_KEY
roles:
llm.preprocess:
provider: openai
model: gpt-4o-mini
mode: chat
params:
temperature: 0.2
max_tokens: 512
llm.inference:
provider: anthropic
model: claude-3-5-sonnet-20241022
mode: chat
params:
temperature: 0.7
max_tokens: 2048
You typically do not edit this by hand; it is generated by higher-level tools (e.g. llmhub CLI/Web).
Basic Usage
from llmhub_runtime.hub import LLMHub
hub = LLMHub(config_path="llmhub.yaml")
response = hub.completion(
role="llm.inference",
messages=[{"role": "user", "content": "Hello"}],
)
print(response)
Embeddings:
embedding = hub.embedding(
role="llm.embedding",
input="Hello world",
)
To override parameters per call:
response = hub.completion(
role="llm.inference",
messages=[...],
params_override={"temperature": 0.1},
)
Architecture Overview
llmhub_runtime is intentionally small and has three main layers:
-
Config layer
models.py– Pydantic models forRuntimeConfig,ProviderConfig,RoleConfig,ResolvedCall.config_loader.py– loads and validatesllmhub.yaml.
-
Resolution layer
resolver.py– maps a logicalrolename to{provider, model, mode, params}, with optional fallback fromdefaults.
-
Execution layer
hub.py– exposes theLLMHubclass:- Resolves roles.
- Calls
any-llm(completion/embedding) with the resolved settings. - Optional hooks for logging/metrics.
All domain-specific errors live in errors.py.
Design Principles
- No provider logic –
llmhub_runtimenever talks to provider SDKs directly; it only callsany-llm. - No discovery or scoring – it assumes
llmhub.yamlalready contains concrete provider/model choices. - Role-first – application code only sees role names; you can swap models by editing/generating
llmhub.yamlwithout changing app code.
Roadmap
- Async APIs (
acompletion,aembedding). - Streaming interfaces.
- More modes (
image,audio,tool). - Tight integration with the
llmhubCLI/Web for config generation.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmhub_runtime-1.0.2.tar.gz.
File metadata
- Download URL: llmhub_runtime-1.0.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ec83abe85675a42331beb2812a56781051e767fe7550ebee51d46b8984386a5
|
|
| MD5 |
140d798d2ea4f6302bfbbf73a5057037
|
|
| BLAKE2b-256 |
aa3a12b921602ab990fa23734ae0c4cf0664bb238285cf597a61e1520582f585
|
File details
Details for the file llmhub_runtime-1.0.2-py3-none-any.whl.
File metadata
- Download URL: llmhub_runtime-1.0.2-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.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbcd7e64147df18faa27e271e21144f99470df84b4c6e1d92270810a05e70424
|
|
| MD5 |
181796648cbed5ced1220a138a208b5b
|
|
| BLAKE2b-256 |
61c284cf3c7e38957f9450aef9a22a8b0b22a0a00f7a451d30f7aa640377410f
|