Module client
Expand description
Synchronous two-dialect chat client for the advisory narrative layer.
The advisory layer speaks to whatever model the operator points it at, in
one of two request shapes: the Anthropic-native /v1/messages API, or the
OpenAI-compatible /chat/completions API that local runners (Ollama, LM
Studio, vLLM) expose. The posture is local-first — with nothing configured,
resolution defaults to a local OpenAI-compatible endpoint.
The client is deliberately blocking: codelore-lib carries no async
runtime, and one advisory completion per invocation does not warrant one. It
uses a single ureq agent with one total timeout and no retries.
Environment reading is confined to LlmEnv::from_process_env; every other
path takes an LlmEnv by reference, so resolve_client is pure over its
input and the resolution matrix is unit-testable without environment races.
Structs§
- Anthropic
Client - Client for the Anthropic-native
/v1/messagesAPI. - LlmEnv
- Raw environment inputs for client resolution, read once at the crate’s only environment-touching site so that resolution itself stays pure.
- Open
AiCompat Client - Client for the OpenAI-compatible
/chat/completionsAPI.
Constants§
- DEFAULT_
ANTHROPIC_ BASE_ URL - Base URL for the Anthropic dialect when the operator sets none.
- DEFAULT_
ANTHROPIC_ MODEL - Model used for the Anthropic dialect when the operator sets no model.
- DEFAULT_
OPENAI_ COMPAT_ BASE_ URL - Base URL for the OpenAI-compatible dialect when the operator sets none — Ollama’s local OpenAI-compatible shim; this default makes the layer local-first.
- REQUEST_
TIMEOUT_ SECS - Total per-request timeout, in seconds. Covers connect through body read.
Traits§
- Chat
Client - A model that turns one system + user exchange into assistant text.
Functions§
- resolve_
client - Resolve a
ChatClientfrom environment inputs (local-first).