config_class.py
Source: sunholo/utils/config_class.py
Classes
ConfigManager
No docstring available.
- init(self, vector_name: str, validate: bool = True)
- Initialize the ConfigManager with a vector name. Requires a local config/ folder holding your configuration files or the env var VAC_CONFIG_FOLDER to be set.
Read more at: https://dev.sunholo.com/docs/config
Args: vector_name (str): The name of the vector in the configuration files. validate (bool): Whether to validate the configurations
Example:
# Usage example:
config = ConfigManager("my_vac")
agent = config.vacConfig("agent")
-
_check_and_reload_configs(self)
- Check if configurations are older than 5 minutes and reload if necessary.
-
_load_configs_from_folder(self, folder)
- Load all configuration files from a specific folder into a dictionary.
Args: folder (str): The path of the folder to load configurations from.
Returns: dict: A dictionary of configurations grouped by their 'kind' key.
- _merge_dicts(self, dict1, dict2)
- Recursively merge two dictionaries. Local values in dict2 will overwrite global values in dict1.
Args: dict1 (dict): The global dictionary. dict2 (dict): The local dictionary.
Returns: dict: The merged dictionary.
- _reload_config_file(self, config_file, filename, is_local=False)
- Helper function to load a config file and update the cache.
Args: config_file (str): The path to the configuration file. filename (str): The name of the configuration file. is_local (bool): Indicates if the config file is from the local folder.
Returns: dict: The loaded configuration.
- agentConfig(self, key: str)
- Fetch a key from 'agentConfig' kind configuration.
Args: key (str): The key to fetch from the configuration.
Returns: str: The value associated with the specified key.
- load_all_configs(self)
- Load all configuration files from the specified directories into a dictionary. Caching is used to avoid reloading files within a 5-minute window.
Returns: dict: A dictionary of configurations grouped by their 'kind' key.
- promptConfig(self, key: str)
- Fetch a key from 'promptConfig' kind configuration.
Args: key (str): The key to fetch from the configuration.
Returns: str: The value associated with the specified key.
- vacConfig(self, key: str)
- Fetch a key from 'vacConfig' kind configuration.
Args: key (str): The key to fetch from the configuration.
Returns: str: The value associated with the specified key.