Expand description
LLM provider abstraction.
A provider takes a transcript plus tool specs and returns either free-form content, structured tool calls, or both. The trait is the only thing the agent depends on; everything beyond it (HTTP, retries, mocking) lives in adapters.
Re-exports§
pub use anthropic::AnthropicProvider;pub use openai::OpenAiProvider;
Modules§
- anthropic
- Anthropic Messages API adapter.
- mock
- Deterministic LLM for tests and offline development.
- openai
- OpenAI-compatible chat-completions adapter.
- search
- Tool search engine: keyword-based discovery of deferred tools.
Structs§
- Completion
- One step of model output.
- Model
Pricing - Per-million-token pricing for one model. USD.
- Retry
Policy - Retry policy for transient LLM provider failures (network timeouts, 5xx).
- Structured
Request - Request for a structured JSON response conforming to a JSON schema.
- Token
Usage - Token usage data from an LLM response.
- Tool
Call - A structured request to invoke one of the registered tools.
- Tool
Spec - JSON-schema description of a tool, sent verbatim to the model.
Traits§
Functions§
- context_
window_ tokens_ for_ model - Returns the context window size in tokens for the given model.
- default_
compact_ threshold_ chars - Compute the default compaction character-count threshold for a model.
- pricing_
for - Returns pricing for a model by looking it up in the bundled
providers.toml. ReturnsNoneif the model is not listed or has no pricing field.
Type Aliases§
- Stream
Sender - Channel sender for streaming partial tokens during a streaming LLM call.
Each
Stringis a delta chunk (partial token) emitted by the provider.