Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
BaseURL string
APIKey string
Model string
Provider Provider
Timeout time.Duration
// BatchSize caps how many texts are sent in a single embeddings API
// call, defaulting to defaultEmbedBatchSize when zero. Most hosted
// embedding APIs enforce a per-request token/count budget - Mistral's
// embeddings endpoint, for one, rejects a request outright with "too
// many tokens overall, split into more batches" rather than truncating,
// so a single call for an entire large document's chunks fails instead
// of just running slowly.
BatchSize int
}
Config holds the configuration for a provider-backed embedder.
func FromEnv ¶
func FromEnv() *Config
FromEnv reads embedding configuration from environment variables:
RAG_EMBEDDING_URL — base URL (e.g. https://api.openai.com/v1 or http://localhost:11434) RAG_EMBEDDING_MODEL — model name (e.g. text-embedding-3-small or nomic-embed-text) RAG_EMBEDDING_API_KEY — API key (optional for Ollama) RAG_EMBEDDING_PROVIDER — "openai" or "ollama" (auto-detected if empty)
func (*Config) IsConfigured ¶
IsConfigured reports whether all required fields are present.
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
Embedder calls a remote embedding API to produce dense float vectors.
func NewFromEnv ¶
func NewFromEnv() *Embedder
NewFromEnv creates an Embedder from environment variables. Returns nil if the required variables are not set (so callers can guard with IsConfigured).
func (*Embedder) EmbedTexts ¶
EmbedTexts implements rag.Embedder. Splits texts into Config.BatchSize- sized groups and calls the provider once per group, concatenating results in order - a single unbounded call for a large document's worth of chunks can be flatly rejected by the provider (see Config.BatchSize).
type Provider ¶
type Provider string
Provider selects which embedding API format to use.
func DetectProviderPublic ¶
DetectProviderPublic is the exported version of detectProvider for use outside this package.