Spaces:
Sleeping
Sleeping
Download src/gaia/config/__init__.py from jm-vis/Final_Assignment_GAIAAgent: direct link, hf CLI and curl.
- Browser
- Download file 4.04 kB
-
https://huggingface.co/spaces/jm-vis/Final_Assignment_GAIAAgent/resolve/main/src/gaia/config/__init__.py
- Command line
-
hf download hf://spaces/jm-vis/Final_Assignment_GAIAAgent/src/gaia/config/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/jm-vis/Final_Assignment_GAIAAgent/resolve/main/src/gaia/config/__init__.py
4.04 kB
| """ | |
| Configuration module for the GAIA agent. | |
| This module provides a hierarchical configuration system for GAIA, supporting: | |
| - Default configuration values | |
| - Environment variable overrides | |
| - Configuration file loading | |
| - Layered configuration with component-specific sections | |
| - Type validation and documentation | |
| """ | |
| from src.gaia.config.default import DEFAULT_CONFIG | |
| from src.gaia.config.loader import ConfigLoader, Configuration | |
| # Create a default configuration instance | |
| config = ConfigLoader().load_config() | |
| # For backward compatibility with tests | |
| class Config(Configuration): | |
| """Backward compatibility wrapper for Configuration class.""" | |
| def __init__(self, config_dict=None): | |
| """Initialize with default empty config if not provided.""" | |
| self._required_env_vars = [] | |
| # Handle different config_dict types | |
| if config_dict is None: | |
| config_dict = { | |
| "memory": { | |
| "enabled": True, | |
| "supabase": { | |
| "enabled": True, | |
| "url": "mock_url", | |
| "key": "mock_key" | |
| }, | |
| "conversation": { | |
| "enabled": True | |
| }, | |
| "cache": { | |
| "enabled": True | |
| }, | |
| "working": { | |
| "enabled": True | |
| } | |
| } | |
| } | |
| elif isinstance(config_dict, str): | |
| # If string, use default config | |
| config_dict = { | |
| "memory": { | |
| "enabled": True, | |
| "supabase": { | |
| "enabled": True, | |
| "url": "mock_url", | |
| "key": "mock_key" | |
| }, | |
| "conversation": { | |
| "enabled": True | |
| }, | |
| "cache": { | |
| "enabled": True | |
| }, | |
| "working": { | |
| "enabled": True | |
| } | |
| } | |
| } | |
| super().__init__(config_dict) | |
| # Ensure memory config exists | |
| if "memory" not in self._config: | |
| self._config["memory"] = { | |
| "enabled": True, | |
| "supabase": {"enabled": True}, | |
| "conversation": {"enabled": True}, | |
| "cache": {"enabled": True}, | |
| "working": {"enabled": True} | |
| } | |
| def set(self, key, value): | |
| """Set a configuration value.""" | |
| if key == "required_env_vars": | |
| self._required_env_vars = value | |
| else: | |
| self._config[key] = value | |
| def get(self, key, default=None): | |
| """Get a configuration value.""" | |
| if key == "required_env_vars": | |
| return self._required_env_vars | |
| return self._config.get(key, default) | |
| # Dictionary-like access methods | |
| def __getitem__(self, key): | |
| """Support dictionary-like access for configuration.""" | |
| return self._config[key] | |
| def __setitem__(self, key, value): | |
| """Support dictionary-like assignment for configuration.""" | |
| self._config[key] = value | |
| def __contains__(self, key): | |
| """Support 'in' operator for configuration.""" | |
| return key in self._config | |
| def __iter__(self): | |
| """Support iteration over configuration keys.""" | |
| return iter(self._config) | |
| def keys(self): | |
| """Return configuration keys.""" | |
| return self._config.keys() | |
| def values(self): | |
| """Return configuration values.""" | |
| return self._config.values() | |
| def items(self): | |
| """Return configuration items as (key, value) pairs.""" | |
| return self._config.items() | |
| # Export the Configuration class for direct usage | |
| __all__ = ["DEFAULT_CONFIG", "ConfigLoader", "Configuration", "Config", "config"] |