Documentation
¶
Overview ¶
Package llmgen is the multi-backend seam for one-shot structured LLM calls: system + user prompt in, schema-validated JSON out. Five backends share it: the Anthropic and OpenAI APIs, the Claude and Codex terminal clients, and local Ollama. Import and learning each resolve the subset they support.
Never imported by hook hot-path packages (dependency contract C2): the API backends link gopheragent + vendor SDKs.
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 API backends) the structured-output operation. 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.