Skip to main content

Crate llmkit_tower

Crate llmkit_tower 

Source
Expand description

Tower-style middleware for llmkit-rs.

Each layer wraps an llmkit_core::LlmProvider and is itself a provider, so they compose into a single Arc<dyn LlmProvider> without Service<Request> generics or sprawling where clauses. Layers:

FallbackProvider chains providers primary → secondary on failure.

Structs§

CostTracking
Provider produced by CostTrackingLayer.
CostTrackingLayer
Tracks per-request and cumulative cost; optionally enforces a budget.
FallbackProvider
Tries providers in order, advancing to the next on a retryable failure.
RateLimit
Provider produced by RateLimitLayer.
RateLimitLayer
Token-bucket rate limiter: capacity tokens refilling over window.
Retry
Provider produced by RetryLayer.
RetryLayer
Configures exponential-backoff retries for retryable errors.
SessionCost
Shared, cloneable handle to the running session cost (USD), in micro-dollars.
Tracing
Provider produced by TracingLayer.
TracingLayer
Emits a tracing span around each call with latency and usage.

Traits§

LlmLayer
Wraps an inner LlmProvider in a new one, adding cross-cutting behaviour.