pub struct EmbeddingConfig {
pub base_url: String,
pub api_key: Option<String>,
pub model: String,
pub timeout_secs: u64,
pub dimension: Option<usize>,
pub preprocessor: PreprocessorConfig,
}Expand description
Configuration for an OpenAI-compatible embedding endpoint.
Fields§
§base_url: StringFull embeddings endpoint URL (e.g. https://api.openai.com/v1/embeddings).
api_key: Option<String>Bearer API key; absent for keyless local servers.
model: StringEmbedding model name (e.g. text-embedding-3-small).
timeout_secs: u64Request timeout in seconds.
dimension: Option<usize>Expected vector dimension; required so startup validates the wiring.
preprocessor: PreprocessorConfigText preprocessing applied before sending the request.
Implementations§
Source§impl EmbeddingConfig
impl EmbeddingConfig
Sourcepub fn new(base_url: impl Into<String>, model: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>, model: impl Into<String>) -> Self
Creates a config for an explicit endpoint URL and model.
Sourcepub fn openai(api_key: impl Into<String>, model: impl Into<String>) -> Self
pub fn openai(api_key: impl Into<String>, model: impl Into<String>) -> Self
OpenAI endpoint preset (https://api.openai.com/v1/embeddings).
Sourcepub fn ollama(model: impl Into<String>) -> Self
pub fn ollama(model: impl Into<String>) -> Self
Ollama endpoint preset (http://localhost:11434/api/embed).
Sourcepub fn azure(
resource_url: impl Into<String>,
api_key: impl Into<String>,
model: impl Into<String>,
) -> Self
pub fn azure( resource_url: impl Into<String>, api_key: impl Into<String>, model: impl Into<String>, ) -> Self
Azure OpenAI endpoint preset; resource_url already contains the
deployment path and api-version query (e.g.
https://{resource}.openai.azure.com/openai/deployments/{id}/embeddings?api-version=2024-02-01).
Sourcepub fn gemini(api_key: impl Into<String>, model: impl Into<String>) -> Self
pub fn gemini(api_key: impl Into<String>, model: impl Into<String>) -> Self
Gemini OpenAI-compatibility endpoint preset
(https://generativelanguage.googleapis.com/v1beta/openai/embeddings).
Sourcepub fn with_api_key(self, api_key: impl Into<String>) -> Self
pub fn with_api_key(self, api_key: impl Into<String>) -> Self
Sets the bearer API key.
Sourcepub fn with_timeout(self, timeout_secs: u64) -> Self
pub fn with_timeout(self, timeout_secs: u64) -> Self
Sets the request timeout in seconds.
Sourcepub fn with_dimension(self, dimension: usize) -> Self
pub fn with_dimension(self, dimension: usize) -> Self
Sets the expected vector dimension.
Sourcepub fn with_preprocessor(self, preprocessor: PreprocessorConfig) -> Self
pub fn with_preprocessor(self, preprocessor: PreprocessorConfig) -> Self
Sets the text preprocessor.