LLMling-models
Health Uyari
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 7 GitHub stars
Code Gecti
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Extra pydantic-ai models, providers and toolsets (human-in-the-loop, model routing, Claude Code, code mode) for AgentPool
LLMling-models
Extra pydantic-ai models: human-in-the-loop models, model routing,
prompt augmentation, remote models, config models and an extended infer_model(). Built for
AgentPool, but everything works with plain pydantic-ai.
Documentation: https://phil65.github.io/LLMling-models/
Installation
uv add llmling-models
Optional extras:
| Extra | Enables |
|---|---|
remote |
Remote model / remote input servers (FastAPI, websockets) |
default |
The full pydantic-ai package with all of its providers |
Quickstart
from pydantic_ai import Agent
from llmling_models import infer_model
# Drop-in replacement for pydantic-ai's model inference, with extra prefixes
model = infer_model("test:Hello from llmling-models")
agent = Agent(model)
result = agent.run_sync("Say hi")
print(result.output) # Hello from llmling-models
Features
- Extended
infer_model(): extra prefixes (input,remote_model:,remote_input:,import:,test:) and comma-separated fallback chains; everything else goes to pydantic-ai. - Models:
InputModel,UserSelectModel,DelegationMultiModel,AugmentedModel,RemoteInputModel,RemoteProxyModel,function_to_model(). - Config models:
llmling_models_configholds pydantic configs (StringModelConfig,OpenAIModelConfig,OpenAICompatibleModelConfig,AnthropicModelConfig, ...) with aget_model()factory.
Extended infer_model
from llmling_models import infer_model
model = infer_model("openai:gpt-4o") # every pydantic-ai id works, e.g.
model = infer_model("openrouter:anthropic/claude-sonnet-4.5") # OPENROUTER_API_KEY
model = infer_model("github-copilot:gpt-5") # GITHUB_COPILOT_API_KEY
model = infer_model("input") # human types the answer
model = infer_model("remote_model:ws://host:8000/v1/completion/stream")
model = infer_model("remote_input:ws://host:8000/v1/chat/stream")
model = infer_model("import:my_package.models:MyModel") # import a Model from a path
model = infer_model("test:Custom response") # TestModel with fixed output
# Fallback chain: tries models in order
model = infer_model("openai:gpt-4o,anthropic:claude-sonnet-4-5")
Providers come from pydantic-ai (xai:, deepseek:, github-copilot:, openai-codex:, ...).
The prefixes llmling-models resolved itself were removed; infer_model names the replacement:
| Removed prefix | Replacement |
|---|---|
grok: |
xai: (pydantic-ai's xai extra) |
copilot: |
github-copilot: (token in GITHUB_COPILOT_API_KEY) |
lm-studio:, perplexity:, zen: |
OpenAICompatibleModelConfig with the service's base URL |
Models
Input Model
Delegates responses to a human, for testing, debugging or hybrid human-AI workflows:
from pydantic_ai import Agent
from llmling_models import InputModel
model = InputModel(
prompt_template="Question: {prompt}",
show_system=True,
input_prompt="Your answer: ",
)
agent = Agent(model=model, system_prompt="You are helping test an input model.")
result = await agent.run("What's your favorite color?")
print(result.output)
Custom input sources can be plugged in via the handler argument (seellmling_models.models.input_model.input_handlers).
User Select Model
Lets the user pick which model answers each prompt:
from pydantic_ai import Agent
from llmling_models import UserSelectModel
model = UserSelectModel(models=["openai:gpt-4o-mini", "anthropic:claude-haiku-4-5"])
agent = Agent(model)
result = await agent.run("What is the meaning of life?")
Delegation Model
A selector model picks the most suitable model for each prompt:
from pydantic_ai import Agent
from llmling_models import DelegationMultiModel
model = DelegationMultiModel(
selector_model="openai:gpt-4o-mini",
models=["openai:gpt-4o", "openai:gpt-4o-mini"],
model_descriptions={
"openai:gpt-4o": "Complex reasoning, math and coding tasks",
"openai:gpt-4o-mini": "Simple queries and chat",
},
selection_prompt="Select the most appropriate model for the task.",
)
agent = Agent(model)
result = await agent.run("Solve this complex mathematical proof...")
Augmented Model
Pre- and post-processes prompts with auxiliary models:
from pydantic_ai import Agent
from llmling_models.models import AugmentedModel
from llmling_models.models.augmented import PrePostPromptConfig
model = AugmentedModel(
main_model="openai:gpt-4o",
pre_prompt=PrePostPromptConfig(
text="Expand this question: {input}", model="openai:gpt-4o-mini"
),
post_prompt=PrePostPromptConfig(
text="Summarize this response concisely: {output}", model="openai:gpt-4o-mini"
),
)
agent = Agent(model)
result = await agent.run("What is AI?")
When streaming (agent.run_stream(), agent.iter()), only the pre-prompt is applied: the main
model's stream is passed through unchanged, so the post-prompt is skipped.
Remote Input and Remote Proxy Models
Forward requests to a remote human operator (RemoteInputModel) or to a model served elsewhere
(RemoteProxyModel), over WebSocket (streaming) or REST. Requires the remote extra.
from pydantic_ai import Agent
from llmling_models.models import RemoteInputModel
model = RemoteInputModel(url="ws://operator:8000/v1/chat/stream", api_key="your-api-key")
agent = Agent(model)
result = await agent.run("What's the meaning of life?")
Serving a pydantic-ai model for RemoteProxyModel:
from llmling_models.models.remote_model.server import ModelServer
server = ModelServer(model="openai:gpt-4o-mini", api_key="your-secret-key")
server.run(host="0.0.0.0", port=8000)
The matching operator server for RemoteInputModel lives inllmling_models.models.remote_input.server.
Model configs
llmling_models_config is a lightweight package of pydantic models for declaring models in
config files:
from llmling_models_config import StringModelConfig
config = StringModelConfig(identifier="openai:gpt-4o-mini", temperature=0.2)
model = config.get_model()
settings = config.get_model_settings()
Any OpenAI-compatible service (LM Studio, Perplexity, Requesty, OpenCode Zen, a self-hosted
gateway) is a type: openai-compatible config:
from llmling_models_config import OpenAICompatibleModelConfig
config = OpenAICompatibleModelConfig(
identifier="qwen/qwen3-coder",
base_url="http://localhost:1234/v1",
provider_name="lm-studio",
)
model = config.get_model()
License
MIT
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi