Skip to main content

Module client

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§

AnthropicClient
Client for the Anthropic-native /v1/messages API.
LlmEnv
Raw environment inputs for client resolution, read once at the crate’s only environment-touching site so that resolution itself stays pure.
OpenAiCompatClient
Client for the OpenAI-compatible /chat/completions API.

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§

ChatClient
A model that turns one system + user exchange into assistant text.

Functions§

resolve_client
Resolve a ChatClient from environment inputs (local-first).