Skip to main content

Crate locode_provider

Crate locode_provider 

Source
Expand description

locode-provider — the Provider trait over an API-agnostic ConversationRequest (ADR-0007), the normalized Completion response, the ProviderError taxonomy, a scripted MockProvider, and the streaming ToolCallAssembler.

One Provider impl = one wire schema (Anthropic Messages, OpenAI Chat/Responses, or mock); gateways (OpenRouter/Bedrock/proxy) are configuration pointed at a schema, not separate impls. v0 ships mock here; the live Anthropic wire is Task 12.

Re-exports§

pub use anthropic::AnthropicProvider;
pub use anthropic::AuthRefresh;
pub use http::HttpFailure;
pub use http::RetryPolicy;
pub use openai::responses::OpenAiResponsesProvider;
pub use openai::OpenAiBackend;
pub use openai::OpenAiModelConfig;
pub use openai::SystemPlacement;

Modules§

anthropic
The Anthropic Messages wire — the one live Provider (Task 12, ADR-0007).
http
The shared HTTP transport layer (hoisted from anthropic/ at Task 18): retry policy + backoff, the HttpFailure carrier, Retry-After parsing, client construction, and schema normalization. Per-wire error classification stays wire-local (body shapes and terminal heuristics genuinely differ).
openai
The OpenAI wire family (Task 18): shared config record, backend detection, and error classification for the Responses wire (and the deferred Chat Completions wire, Task 17).

Structs§

Completion
One normalized completion: the parsed result of a single model call (ADR-0007).
ConversationRequest
One provider-neutral sampling request (ADR-0007).
MockProvider
A provider that replays a fixed script of results, one per complete() call.
RepairStats
What a repair_pairing pass changed.
SamplingArgs
Provider-neutral sampling knobs — the common core only.
ToolCallAssembler
Accumulates streamed tool-call fragments by content-block index.

Enums§

AssembleError
A failure assembling streamed tool-call arguments.
CacheHint
Where the wire should place prompt-cache breakpoints (ADR-0007).
CompletionDelta
One incremental piece of a streaming completion (ADR-0021), normalized across wires — the display-oriented side channel of crate::Provider::stream.
Effort
One rung of the locode effort ladder.
ProviderError
Why a model call failed (ADR-0007).
ReasoningEffort
A neutral reasoning-effort level, mapped per-wire (ADR-0007).
StopReason
Why the model stopped generating (Anthropic-shaped, provider-neutral).

Constants§

DEFAULT_MAX_TOKENS
The default output-token budget for one sample.

Traits§

Provider
A model-sampling wire: builds a request, calls the model, normalizes the response.

Functions§

repair_pairing
Make messages valid to send: dedup duplicate tool_results, then synthesize is_error results for any dangling tool_use. Idempotent — a valid transcript passes through unchanged.