Skip to main content

Crate polyc_llm

Crate polyc_llm 

Source
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

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 error::parse_retry_after;
pub use model_info::FALLBACK_CONTEXT_WINDOW;
pub use model_info::ModelInfo;
pub use model_info::lookup_model;
pub use model_info::lookup_model_or_fallback;
pub use preflight::PreflightReport;
pub use preflight::ProbeOutcome;
pub use preflight::preflight;
pub use request::APPROVAL_STATUS_GROUND_RULE;
pub use request::CacheHint;
pub use request::CompletionRequest;
pub use request::Content;
pub use request::GATED_TOOL_APPROVAL_NOTE;
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;

Modules§

chunk
Streaming response types: Chunk, Usage, and StopReason.
erased
Type erasure for LlmProvider so the control plane can hold a single Arc<dyn LlmProvider> regardless of which backend is configured.
error
LlmError marker trait and reference DummyError implementation.
model_info
Bundled model catalog: per-model context-window facts and the longest-prefix lookup that drives compaction.
preflight
Startup preflight: verify a backend actually delivers native tool calling and schema-constrained structured output, against the live endpoint.
request
Request-side LLM types: CompletionRequest, Message, Content, ToolSpec, ToolChoice, and JsonSchema.
sse
Shared Server-Sent Events framing helpers for streaming providers.
turn
Turn helpers: a StubProvider for wiring/tests and collect_turn, which folds a provider’s Chunk stream into a single TurnOutput.

Traits§

LlmProvider
The seam between the planner and any concrete LLM backend.

Functions§

init_metrics
Force-register this crate’s Prometheus call-latency histogram.