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

Method load_retrieval_config

AskAgent/python/core/config.py:318–353  ·  view source on GitHub ↗
(self, path: str = "config_retrieval.yaml")

Source from the content-addressed store, hash-verified

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
320 full_path = os.path.join(self.config_directory, path)
321
322 try:
323 with open(full_path) as f:
324 data = yaml.safe_load(f)
325 except FileNotFoundError:
326 # If config file doesn't exist, use defaults
327 print(f"Warning: {path} not found. Using default retrieval configuration.")
328 data = {
329 "preferred_endpoint": "default",
330 "endpoints": {}
331 }
332
333 # No longer using preferred_endpoint - now using enabled field on each endpoint
334 self.retrieval_endpoints: dict[str, RetrievalProviderConfig] = {}
335
336 # Get the write endpoint for database modifications
337 self.write_endpoint: str = data.get("write_endpoint")
338
339 # Changed from providers to endpoints
340 for name, cfg in data.get("endpoints", {}).items():
341 # Use the new method for all configuration values
342 self.retrieval_endpoints[name] = RetrievalProviderConfig(
343 api_key=self._get_config_value(cfg.get("api_key_env")),
344 api_key_env=cfg.get("api_key_env"), # Store the env var name
345 api_endpoint=self._get_config_value(cfg.get("api_endpoint_env")),
346 api_endpoint_env=cfg.get("api_endpoint_env"), # Store the env var name
347 database_path=self._get_config_value(cfg.get("database_path")),
348 index_name=self._get_config_value(cfg.get("index_name")),
349 db_type=self._get_config_value(cfg.get("db_type")), # Add db_type
350 enabled=cfg.get("enabled", False), # Add enabled field
351 use_knn=cfg.get("use_knn"),
352 vector_type=cfg.get("vector_type")
353 )
354
355 def load_webserver_config(self, path: str = "config_webserver.yaml"):
356 # Build the full path to the config file using the config directory

Callers 2

__init__Method · 0.95

Calls 3

_get_config_valueMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected