Documentation
¶
Index ¶
Constants ¶
const ( DefaultLocalProvider = "local" DefaultLocalModel = "local-hash-v1" )
const ( OllamaProvider = "ollama" DefaultOllamaModel = "nomic-embed-text" DefaultOllamaHost = "http://localhost:11434" )
const ( OpenRouterProvider = "openrouter" DefaultOpenRouterModel = "openai/text-embedding-3-small" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LocalProvider ¶
type LocalProvider struct {
// contains filtered or unexported fields
}
func NewLocalProvider ¶
func NewLocalProvider(model string) LocalProvider
func (LocalProvider) Model ¶
func (p LocalProvider) Model() string
func (LocalProvider) Name ¶
func (p LocalProvider) Name() string
type OllamaEmbeddingProvider ¶
type OllamaEmbeddingProvider struct {
// contains filtered or unexported fields
}
OllamaEmbeddingProvider runs embeddings against a locally hosted Ollama server. No API key required; the only configuration is the base URL (default http://localhost:11434, overridable via OLLAMA_HOST) and the model name (default nomic-embed-text — 137M params, 768-d, widely available, decent retrieval quality).
This intentionally talks to Ollama's native /api/embed endpoint rather than its OpenAI-compatible /v1/embeddings endpoint because the native shape is simpler and supports batching directly.
func NewOllamaProvider ¶
func NewOllamaProvider(model string) (OllamaEmbeddingProvider, error)
NewOllamaProvider builds the provider, reading OLLAMA_HOST from the env when set. We don't probe the server here — defer that to first Embed call so the provider is cheap to construct (matches LocalProvider's behavior).
func (OllamaEmbeddingProvider) Model ¶
func (p OllamaEmbeddingProvider) Model() string
func (OllamaEmbeddingProvider) Name ¶
func (p OllamaEmbeddingProvider) Name() string
type OpenRouterEmbeddingProvider ¶
type OpenRouterEmbeddingProvider struct {
// contains filtered or unexported fields
}
OpenRouterEmbeddingProvider talks to OpenRouter's OpenAI-compatible /v1/embeddings endpoint. The API key comes from OPENROUTER_API_KEY; the model is configurable (default: openai/text-embedding-3-small, the cheap 1536-d model that benchmarks well on retrieval).
func NewOpenRouterProvider ¶
func NewOpenRouterProvider(model string) (OpenRouterEmbeddingProvider, error)
NewOpenRouterProvider constructs the provider, reading the API key from the environment. Returns an error if OPENROUTER_API_KEY is unset — callers can then fall back to the local provider or surface the error to the operator.
func (OpenRouterEmbeddingProvider) Embed ¶
Embed sends a single string to OpenRouter and returns the vector. We use the single-input form (input: "string") because the Provider interface is one-text-at-a-time; the batch path lives in the bench harness, which talks to OpenRouter directly when it needs throughput.
func (OpenRouterEmbeddingProvider) Model ¶
func (p OpenRouterEmbeddingProvider) Model() string
func (OpenRouterEmbeddingProvider) Name ¶
func (p OpenRouterEmbeddingProvider) Name() string