Documentation
¶
Overview ¶
Package llm is the thin off-gate LLM provider layer for archfit's enrich and explain commands. It is NEVER part of the check gate: the arch ring test forbids any internal package from importing it — only cmd may.
The interface is one method deep. Classify/explain prompt construction and response parsing are archfit-side concerns (cmd/enrich), not provider methods. Determinism of the enrich workflow comes from the content-hash cache (cache.go) and the human-reviewed pinned labels — never from sampling parameters: current Anthropic Opus-tier models reject temperature outright.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnthropicProvider ¶
type AnthropicProvider struct {
// contains filtered or unexported fields
}
AnthropicProvider completes requests via the official anthropic-sdk-go Messages API. Auth comes from the standard ANTHROPIC_API_KEY env var (the SDK reads it); archfit never stores keys in config.
No temperature is sent: current Opus-tier models reject sampling parameters (400), and enrich determinism comes from the cache + reviewed labels anyway.
func NewAnthropic ¶
func NewAnthropic(model string) (*AnthropicProvider, error)
NewAnthropic returns a provider for the given model id (e.g. "claude-opus-4-8"). Returns NotConfiguredError when ANTHROPIC_API_KEY is not set — fail at construction, not on the first network call.
func (*AnthropicProvider) Complete ¶
Complete executes one non-streaming Messages call and concatenates the response text blocks.
func (*AnthropicProvider) Name ¶
func (p *AnthropicProvider) Name() string
Name returns "anthropic/<model>".
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a content-addressed Provider decorator. A hit skips the network entirely, which is what makes `enrich` replay deterministic: same provider, model, prompts → same cache key → byte-identical response. The cache directory is committable — a committed cache replays identically across machines. Corrupt entries are refetched, never fatal.
func NewCache ¶
NewCache wraps inner with a file cache rooted at dir (e.g. <repo>/.archfit-cache/llm). The directory is created lazily.
type NotConfiguredError ¶
NotConfiguredError reports a provider that cannot run in this environment (missing API key, unknown provider name). Commands turn it into exit 3 with a setup hint; it must never be silently swallowed.
func (*NotConfiguredError) Error ¶
func (e *NotConfiguredError) Error() string
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider completes requests via the official openai-go Chat Completions API. It also serves Ollama through its OpenAI-compatible endpoint (NewOllama) — base-URL swap, no separate SDK.
func NewOllama ¶
func NewOllama(baseURL, model string) *OpenAIProvider
NewOllama returns a provider talking to a local (or remote) Ollama via its OpenAI-compatible endpoint. No API key required; baseURL defaults to http://localhost:11434/v1 when empty.
func NewOpenAI ¶
func NewOpenAI(model string) (*OpenAIProvider, error)
NewOpenAI returns a provider for the given model id. Returns NotConfiguredError when OPENAI_API_KEY is not set.
func (*OpenAIProvider) Name ¶
func (p *OpenAIProvider) Name() string
Name returns "<tag>/<model>" (e.g. "ollama/qwen2.5-coder").
type Provider ¶
type Provider interface {
// Name identifies provider+model (e.g. "anthropic/claude-opus-4-8");
// part of the cache key, so it must be stable.
Name() string
// Complete executes the request and returns the text response.
Complete(ctx context.Context, req Request) (Response, error)
}
Provider executes one completion. Implementations: Anthropic, OpenAI, Ollama (OpenAI-compatible), and the content-hash Cache decorator.