MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / load_embedding_config

Method load_embedding_config

AskAgent/python/core/config.py:280–316  ·  view source on GitHub ↗

Load embedding model configuration.

(self, path: str = "config_embedding.yaml")

Source from the content-addressed store, hash-verified

278 )
279
280 def load_embedding_config(self, path: str = "config_embedding.yaml"):
281 """Load embedding model configuration."""
282 # Build the full path to the config file using the config directory
283 full_path = os.path.join(self.config_directory, path)
284
285 try:
286 with open(full_path) as f:
287 data = yaml.safe_load(f)
288 except FileNotFoundError:
289 # If config file doesn't exist, use defaults
290 print(f"Warning: {path} not found. Using default embedding configuration.")
291 data = {
292 "preferred_provider": "openai",
293 "providers": {}
294 }
295
296 self.preferred_embedding_provider: str = data["preferred_provider"]
297 self.embedding_providers: dict[str, EmbeddingProviderConfig] = {}
298
299 for name, cfg in data.get("providers", {}).items():
300 # Extract configuration values from the YAML
301 api_key = self._get_config_value(cfg.get("api_key_env"))
302 api_endpoint = self._get_config_value(cfg.get("api_endpoint_env"))
303 api_version = self._get_config_value(cfg.get("api_version_env"))
304 model = self._get_config_value(cfg.get("model"))
305 config = self._get_config_value(cfg.get("config"))
306 auth_method = self._get_config_value(cfg.get("auth_method"), "api_key")
307
308 # Create the embedding provider config
309 self.embedding_providers[name] = EmbeddingProviderConfig(
310 api_key=api_key,
311 endpoint=api_endpoint,
312 api_version=api_version,
313 model=model,
314 config=config,
315 auth_method=auth_method
316 )
317
318 def load_retrieval_config(self, path: str = "config_retrieval.yaml"):
319 # Build the full path to the config file using the config directory

Calls 3

_get_config_valueMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected