Summary
Create a unified embedding provider interface that supports OpenAI, Ollama, Cohere, Azure OpenAI, and HuggingFace TEI. Users configure once, swap providers without code changes.
Motivation
OpenAI lock-in is the #1 objection in enterprise conversations:
Provider interface
// pkg/embedding/provider.go
type Provider interface {
Embed(ctx context.Context, text string) ([]float32, error)
EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
Dimension() int
Name() string
}
// Factory function
func NewProvider(cfg ProviderConfig) (Provider, error)
Supported providers
| Provider |
Config key |
Endpoint |
Models |
| OpenAI |
openai |
api.openai.com |
text-embedding-3-small, text-embedding-3-large |
| Azure OpenAI |
azure |
{deployment}.openai.azure.com |
Same models, Azure-hosted |
| Ollama |
ollama |
localhost:11434 |
nomic-embed-text, mxbai-embed-large |
| Cohere |
cohere |
api.cohere.com |
embed-english-v3.0, embed-multilingual-v3.0 |
| HuggingFace TEI |
huggingface |
configurable |
Any model via Text Embeddings Inference |
Config file support
# distill.yaml
embedding:
provider: "ollama" # openai | azure | ollama | cohere | huggingface
model: "nomic-embed-text"
host: "http://localhost:11434" # for ollama/huggingface
api_key: "${EMBEDDING_API_KEY:-}" # for cloud providers
# Azure-specific
azure_deployment: "my-embedding"
azure_api_version: "2024-02-01"
# Batch settings
batch_size: 100 # max texts per batch call
max_retries: 3
timeout: "30s"
CLI flags
distill api --embedding-provider ollama --embedding-model nomic-embed-text
distill api --embedding-provider azure --embedding-model text-embedding-3-small
distill api --embedding-provider cohere --embedding-model embed-english-v3.0
Deliverables
Acceptance Criteria
Summary
Create a unified embedding provider interface that supports OpenAI, Ollama, Cohere, Azure OpenAI, and HuggingFace TEI. Users configure once, swap providers without code changes.
Motivation
OpenAI lock-in is the
#1objection in enterprise conversations:Provider interface
Supported providers
openaiazureollamacoherehuggingfaceConfig file support
CLI flags
Deliverables
pkg/embedding/provider.go- Interface + factorypkg/embedding/openai/- Existing, refactored to implement interfacepkg/embedding/ollama/client.go- Ollama HTTP clientpkg/embedding/azure/client.go- Azure OpenAI clientpkg/embedding/cohere/client.go- Cohere clientpkg/embedding/huggingface/client.go- HuggingFace TEI clientcmd/api.go,cmd/serve.go,cmd/mcp.goto use factorypkg/config/config.gowith provider configdocker-compose.ymlexample with Ollama sidecarAcceptance Criteria