Files
agentic-coding-workflow/internal/infra/llm/embedder.go
T
2026-06-22 08:55:57 +08:00

26 lines
1.0 KiB
Go

package llm
import (
"context"
"errors"
)
// ErrEmbeddingsUnsupported is returned by providers that have no embeddings API
// (notably Anthropic). Callers degrade to keyword fallback when they see it.
var ErrEmbeddingsUnsupported = errors.New("llm: embeddings not supported by provider")
// PlatformEmbeddingDims is the single vector dimension baked into the pgvector
// columns at migration time (vector(1536)). Embedding endpoints MUST be
// configured with a model that produces this dimension; the build runner rejects
// mismatched dims rather than corrupting the index.
const PlatformEmbeddingDims = 1536
// Embedder is implemented by providers that expose a text-embeddings endpoint.
// Embed returns one vector per input, in input order. EmbedDims returns the
// vector length the given model produces (used to validate against the fixed
// pgvector column dimension before inserting).
type Embedder interface {
Embed(ctx context.Context, modelID string, inputs []string) ([][]float32, error)
EmbedDims(modelID string) int
}