Documentation
¶
Overview ¶
Package llm is the Mesh BYOAI chat boundary for the sync-curator (S2.1). It is stdlib-only (no SDK) and speaks three backends behind one Complete interface:
- cli (the default): the team's existing coding-agent CLI (e.g. `claude -p`), already authenticated in the dev's IDE. The prompt goes in on stdin, the completion comes back on stdout. No API key for the curator to hold: it reuses whatever agent the dev already runs. This is how most devs use Mesh.
- anthropic: Anthropic Messages API with an explicit key (best when running headless/always-on where no IDE CLI is logged in).
- local: any OpenAI-compatible /v1/chat/completions endpoint (e.g. a local Ollama), so a sovereign vault never egresses.
Keys and vault content are never logged.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAuth = errors.New("llm: authentication failed (check the API key)")
ErrAuth (401/403) is an operator config problem (bad/expired key), not a poison job: the caller should wait for the key to be fixed, NOT burn the attempt cap.
var ErrRateLimited = errors.New("llm: rate limited")
ErrRateLimited (429) is transient: the caller should back off and retry the whole pass later, not hammer the rest of the batch.
var ErrTruncated = errors.New("llm: output truncated at max_tokens")
ErrTruncated means the model hit its output budget (stop_reason max_tokens / finish_reason length), so the completion is partial and must not be trusted as a complete merged note.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Complete(ctx context.Context, system, user string) (string, error)
Describe() string // agent + model, no secrets; for status/logging
}
Client turns a (system, user) prompt into completion text.
func NewFromEnv ¶
NewFromEnv builds the curator's LLM client from MESH_CURATOR_* env:
MESH_CURATOR_AGENT cli (default) | anthropic | local MESH_CURATOR_MODEL model id (anthropic default claude-sonnet-4-6; required for local) MESH_CURATOR_MAXTOK max output tokens (default 8192; anthropic/local only) cli: MESH_CURATOR_CMD (default "claude -p"), MESH_CURATOR_CMD_TIMEOUT (seconds) anthropic: MESH_ANTHROPIC_KEY (fallback ANTHROPIC_API_KEY), MESH_ANTHROPIC_BASE local: MESH_CURATOR_ENDPOINT (e.g. http://localhost:11434/v1), MESH_CURATOR_KEY