Documentation
¶
Overview ¶
Package llm provides embedding clients for the configured provider. It is ported and trimmed from Seam v1 internal/ai: the chat completion, ChromaDB, and async task-queue machinery are gone; only text -> vector embedding remains, since P1 needs brute-force cosine search over locally stored vectors.
OpenAI is the first-class provider; Ollama is the local/dev provider (no API cost). Anthropic has no embeddings API and is rejected by the factory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnavailable = errors.New("embedding provider unavailable") // ErrAuth indicates authentication with the provider failed. ErrAuth = errors.New("embedding provider authentication failed") // ErrRateLimited indicates the provider throttled the request. ErrRateLimited = errors.New("embedding provider rate limited") // ErrConfig indicates the client itself is misconfigured: the request could // not be built at all, so no provider was contacted and no retry can help. // The factories below reject a bad base_url up front, so a client that // exists should never produce this at request time. ErrConfig = errors.New("llm client misconfigured") )
Provider-agnostic sentinel errors. Callers (e.g. recall) use errors.Is to decide whether to degrade to lexical-only search when embedding is unavailable.
The split that matters is remote vs local. ErrUnavailable, ErrAuth, and ErrRateLimited all describe a provider that answered badly or not at all: nothing in this process is wrong, so degrading to lexical-only search is honest and the condition may clear on its own. ErrConfig describes a client that could not even form the request -- degrading on that would hide a local defect behind quietly worse results for as long as the daemon runs.
Functions ¶
This section is empty.
Types ¶
type Chat ¶
type Chat interface {
Complete(ctx context.Context, system, user string) (string, error)
Model() string
}
Chat turns a system + user prompt into a single text completion. It backs the gardener's session digests; it is intentionally minimal (no streaming, no tool use). Implementations are safe for concurrent use.
type Embedder ¶
type Embedder interface {
Embed(ctx context.Context, text string) ([]float32, error)
Model() string
}
Embedder turns text into a dense vector. Implementations are safe for concurrent use. Model identifies which model produced the vectors so the store can scope a cosine search to a single model space.
type OllamaEmbedder ¶
type OllamaEmbedder struct {
// contains filtered or unexported fields
}
OllamaEmbedder calls a local Ollama server's POST /api/embed. Ported from Seam v1 internal/ai/ollama.go (embedding path only).
func NewOllamaEmbedder ¶
func NewOllamaEmbedder(baseURL, model string) *OllamaEmbedder
NewOllamaEmbedder returns an embedder for a local Ollama model. An empty baseURL uses the default localhost endpoint.
func (*OllamaEmbedder) Model ¶
func (c *OllamaEmbedder) Model() string
Model returns the embedding model name.
type OpenAIEmbedder ¶
type OpenAIEmbedder struct {
// contains filtered or unexported fields
}
OpenAIEmbedder calls POST {baseURL}/embeddings. It is compatible with OpenAI, Azure OpenAI, and any OpenAI-compatible endpoint. Ported from Seam v1 internal/ai/openai_embedder.go.
func NewOpenAIEmbedder ¶
func NewOpenAIEmbedder(apiKey, baseURL, model string, dims int) *OpenAIEmbedder
NewOpenAIEmbedder returns an OpenAI embeddings client. An empty baseURL uses the default endpoint. dims of 0 omits the dimensions field.
func (*OpenAIEmbedder) Model ¶
func (c *OpenAIEmbedder) Model() string
Model returns the embedding model name.