INNER CODE UNIT · Python

_load_config

derisk-ai/OpenDerisk · packages/derisk-core/src/derisk/agent/core_v2/main.py:61

    def _load_config(self, config_path: Optional[str], env_prefix: str) -> Dict[str, Any]:
        """加载配置"""
        config = {
            "host": os.getenv(f"{env_prefix}HOST", "0.0.0.0"),
            "port": int(os.getenv(f"{env_prefix}PORT", "8080")),
            "log_level": os.getenv(f"{env_prefix}LOG_LEVEL", "INFO"),
            "model": os.getenv("OPENAI_MODEL", "gpt-4"),
            "api_key": os.getenv("OPENAI_API_KEY", ""),
            "max_steps": int(os.getenv(f"{env_prefix}MAX_STEPS", "100")),
            "storage_backend": os.getenv(f"{env_prefix}STORAGE_BACKEND", "memory"),
            "storage_path": os.getenv(f"{env_prefix}STORAGE_PATH", ".agent_state"),
        }
        
        if config_path and Path(config_path).exists():
            try:
                import tomli
                with open(config_path, "rb") as f:
                    file_config = tomli.load(f)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…