Skip to main content

cognee_embedding/
provider.rs

1use serde::{Deserialize, Serialize};
2
3/// Selects the backend used to generate embeddings.
4///
5/// Matches the Python SDK `EMBEDDING_PROVIDER` env var values so that a shared
6/// `.env` file works without modification across both SDKs.
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
8#[serde(rename_all = "snake_case")]
9pub enum EmbeddingProvider {
10    /// Local ONNX inference (existing engine). Equivalent to Python's "fastembed" provider.
11    #[default]
12    Onnx,
13    /// Alias for Onnx — accepts Python env files using EMBEDDING_PROVIDER=fastembed unchanged.
14    /// Deserialized as Onnx internally.
15    #[serde(alias = "fastembed")]
16    Fastembed,
17    /// OpenAI API or any OpenAI-compatible server (llama.cpp, vLLM, TEI, etc.).
18    /// In Python, EMBEDDING_PROVIDER=openai uses LiteLLMEmbeddingEngine; in Rust we use a
19    /// direct-HTTP engine. Both "openai" and "openai_compatible" map to the same engine.
20    #[serde(rename = "openai")]
21    OpenAi,
22    /// Explicit alias for self-hosted OpenAI-compatible servers.
23    /// Identical engine to OpenAi; exists so Python "openai_compatible" env files work unchanged.
24    #[serde(rename = "openai_compatible")]
25    OpenAiCompatible,
26    /// Ollama /api/embed endpoint (not OpenAI-compatible format).
27    Ollama,
28    /// Zero vectors; for testing. Activated by EMBEDDING_PROVIDER=mock or MOCK_EMBEDDING=true.
29    Mock,
30}