Expand description
Provider-agnostic LLM trait and wire types for polychrome.
This crate defines the LlmProvider trait that every concrete provider
backend implements, and the language-shaped Rust types that flow through it.
LlmProvider is the seam that lets the planner swap LLM backends
without touching its own code: one impl crate per provider, dispatched
behind a dyn LlmProvider trait object.
§Modules
request—CompletionRequestand everything reachable from it (Message,Content,ToolSpec,ToolChoice).chunk—Chunk(streaming response events) and friends (Usage,StopReason).error— theLlmErrortrait bound thatLlmProvider::Errormust satisfy.
The trait itself lives in this crate root; the wire types live in the modules above and are re-exported here for convenience.
Re-exports§
pub use chunk::Chunk;pub use chunk::StopReason;pub use chunk::Usage;pub use erased::BoxError;pub use erased::DynProvider;pub use erased::ErasedProvider;pub use erased::into_dyn;pub use error::LlmError;pub use error::LlmErrorKind;pub use error::kind_from_http_status;pub use request::CompletionRequest;pub use request::Content;pub use request::ImageRef;pub use request::JsonSchema;pub use request::Message;pub use request::Role;pub use request::ToolCall;pub use request::ToolChoice;pub use request::ToolResult;pub use request::ToolSpec;pub use request::humanize_tool_name;
Modules§
- chunk
- Streaming response types:
Chunk,Usage, andStopReason. - erased
- Type erasure for
LlmProviderso the control plane can hold a singleArc<dyn LlmProvider>regardless of which backend is configured. - error
LlmErrormarker trait and referenceDummyErrorimplementation.- request
- Request-side LLM types:
CompletionRequest,Message,Content,ToolSpec,ToolChoice, andJsonSchema. - sse
- Shared Server-Sent Events framing helpers for streaming providers.
- turn
- Turn helpers: a
StubProviderfor wiring/tests andcollect_turn, which folds a provider’sChunkstream into a singleTurnOutput.
Traits§
- LlmProvider
- The seam between the planner and any concrete LLM backend.