Expand description
Provider trait and request types.
This module defines two core abstractions:
-
Provider— the trait every backend implements. It uses Rust 2024’s native async-fn-in-traits (AFIT), so implementations are straightforwardasync fns with no macro overhead. -
DynProvider— an object-safe mirror ofProviderthat uses boxed futures. A blanketimpl<T: Provider> DynProvider for Tbridges the two, so any concrete provider can be stored asBox<dyn DynProvider>orArc<dyn DynProvider>with zero boilerplate.
§When to use which
| Situation | Use |
|---|---|
| Generic code that knows the concrete type | Provider |
Need to store providers in a collection or behind dyn | DynProvider |
| Implementing a new backend | impl Provider for MyBackend |
§Request parameters
All request configuration lives in ChatParams. It serializes
cleanly to JSON (for logging / replay) with the exception of
timeout and
extra_headers, which are transport
concerns and are #[serde(skip)]’d.
Structs§
- Chat
Params - Parameters for a chat completion request.
- Json
Schema - A JSON Schema document used for structured output or tool parameters.
- Provider
Metadata - Describes a provider instance: its name, model, and capabilities.
- Tool
Definition - A tool the model can invoke during generation.
- Tool
Retry Config - Configuration for automatic retries when a tool execution fails.
Enums§
- Capability
- A feature that a provider may or may not support.
- Tool
Choice - Controls whether the model should use tools and, if so, which ones.
Traits§
- DynProvider
- Object-safe counterpart of
Providerfor dynamic dispatch. - Provider
- The core trait every LLM provider implements.
Type Aliases§
- Retry
Predicate - Retry behavior predicate type.