|
""" |
|
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 |
|
|
|
|
|
config = ConfigLoader().load_config() |
|
|
|
|
|
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 = [] |
|
|
|
|
|
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): |
|
|
|
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) |
|
|
|
|
|
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) |
|
|
|
|
|
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() |
|
|
|
|
|
__all__ = ["DEFAULT_CONFIG", "ConfigLoader", "Configuration", "Config", "config"] |