llm

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

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

View Source
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.

View Source
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.

View Source
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

func NewFromEnv() (Client, error)

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

type Func

type Func func(ctx context.Context, system, user string) (string, error)

Func adapts a function to a Client (used by tests + the e2e stub curator).

func (Func) Complete

func (f Func) Complete(ctx context.Context, system, user string) (string, error)

func (Func) Describe

func (f Func) Describe() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL