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.
Structs§
- Completion
- One step of model output.
- Model
Pricing - Per-million-token pricing for one model. USD.
- 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§
- load_
pricing_ from_ yaml - Load pricing from a YAML file. The file should have a “models” key mapping model names to pricing structs. Returns a HashMap of model name -> ModelPricing.
- pricing_
for - Returns pricing for known models, or None if unknown.
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.