Create a new `OpenAI` embedding provider
(config: EmbeddingConfig)
| 209 | impl OpenAIEmbeddingProvider { |
| 210 | /// Create a new `OpenAI` embedding provider |
| 211 | pub fn new(config: EmbeddingConfig) -> GraphBitResult<Self> { |
| 212 | if config.provider != EmbeddingProvider::OpenAI { |
| 213 | return Err(GraphBitError::config( |
| 214 | "Invalid provider type for OpenAI".to_string(), |
| 215 | )); |
| 216 | } |
| 217 | |
| 218 | let client = reqwest::Client::builder() |
| 219 | .timeout(std::time::Duration::from_secs( |
| 220 | config.timeout_seconds.unwrap_or(30), |
| 221 | )) |
| 222 | .build() |
| 223 | .map_err(|e| GraphBitError::llm(format!("Failed to create HTTP client: {e}")))?; |
| 224 | |
| 225 | Ok(Self { config, client }) |
| 226 | } |
| 227 | |
| 228 | /// Get the API base URL |
| 229 | fn base_url(&self) -> &str { |