MCPcopy Create free account
hub / github.com/FareedKhan-dev/ai-long-task / load_config

Function load_config

config.py:451–470  ·  view source on GitHub ↗

Load configuration from a YAML file, or create a default config.

(config_path: Optional[Union[str, Path]] = None)

Source from the content-addressed store, hash-verified

449
450
451def load_config(config_path: Optional[Union[str, Path]] = None) -> Config:
452 """Load configuration from a YAML file, or create a default config."""
453 if config_path and os.path.exists(config_path):
454 # If a path is provided and the file exists, load from YAML
455 config = Config.from_yaml(config_path)
456 else:
457 # Otherwise, create a default Config object
458 config = Config()
459
460 # Try to populate API key and base URL from environment variables as a fallback
461 api_key = os.environ.get("OPENAI_API_KEY")
462 api_base = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1")
463
464 config.llm.update_model_params({"api_key": api_key, "api_base": api_base})
465
466 # Ensure the system message from the prompt config is available to individual models,
467 # in case it's not provided directly by the prompt sampler during a call.
468 config.llm.update_model_params({"system_message": config.prompt.system_message})
469
470 return config

Callers 2

main_asyncFunction · 0.90
_run_evolution_asyncFunction · 0.90

Calls 4

ConfigClass · 0.85
from_yamlMethod · 0.80
getMethod · 0.80
update_model_paramsMethod · 0.80

Tested by

no test coverage detected