Documentation
¶
Overview ¶
Package llmgen is the multi-backend seam for one-shot structured LLM calls: system + user prompt in, schema-validated JSON out. Three backends share it — the Anthropic API (strongest: server-side forced-tool schema), the claude CLI (subscription-billed, no key), and local Ollama (free, private). Both the import reconciler and the learning pipelines build on this seam, so a user's backend choice works everywhere culi calls a model.
Never imported by hook hot-path packages (dependency contract C2): the anthropic backend links gopheragent + the vendor SDK.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator interface {
Generate(ctx context.Context, system, user, name string, schema map[string]any, out any) (Usage, error)
ModelName() string
}
Generator is one structured-output call: decode the model's JSON reply into out, which must match schema. name labels the call in errors and (for the anthropic backend) the forced tool. Implementations are safe for sequential reuse; none are goroutine-safe by contract.
func NewAnthropic ¶
NewAnthropic builds a generator on the given model. apiKeyFile is optional (""): when set, the ANTHROPIC_API_KEY is read from that file (headless learning can't rely on the env var reaching a hook-spawned process); when empty, gopheragent reads ANTHROPIC_API_KEY from the environment as before. Temperature 0: re-running the same call should produce the same output, so review conclusions survive a re-run (best-effort — Anthropic has no seed).
func NewCLI ¶
NewCLI builds a generator on the claude CLI found in PATH. tokenFile is optional (""): when set, each headless call reads a CLAUDE_CODE_OAUTH_TOKEN from that file and injects it into the subprocess env — needed for headless background learning, since Claude Code does not hand its OAuth token to hook-spawned processes.