""" Integration module for backward compatibility with existing code. This module provides aliases and compatibility functions to ensure that code using the previous utility functions will continue to work with the consolidated implementations. """ import logging from typing import Dict, Any, Optional # Import the consolidated implementations from src.gaia.utils.common import ( setup_logging, safe_execute, get_nested_value, set_nested_value, load_file_content, load_json_file, validate_api_key, format_error_message ) from src.gaia.utils.config_utils import ( load_from_env, load_from_file, load_from_env_file, merge_configs, find_config_file, get_config_value, convert_value_type ) from src.gaia.utils.formatting_utils import ( FORMAT_TYPES, extract_answer, extract_number, extract_date, extract_boolean, extract_list, extract_entity, extract_structured_data, format_answer, validate_answer_format, process_answer ) logger = logging.getLogger("gaia_agent.utils.integration") # Re-export all the consolidated functions under their original namespaces __all__ = [ # Common utilities 'setup_logging', 'safe_execute', 'get_nested_value', 'set_nested_value', 'load_file_content', 'load_json_file', 'validate_api_key', 'format_error_message', # Config utilities 'load_from_env', 'load_from_file', 'load_from_env_file', 'merge_configs', 'find_config_file', 'get_config_value', 'convert_value_type', # Formatting utilities 'FORMAT_TYPES', 'extract_answer', 'extract_number', 'extract_date', 'extract_boolean', 'extract_list', 'extract_entity', 'extract_structured_data', 'format_answer', 'validate_answer_format', 'process_answer', # Legacy compatibility functions 'format_response' ] # Backward compatibility functions def format_response(response: str, expected_format: Optional[str] = None) -> Dict[str, Any]: """ Legacy compatibility function for format_response. This function is kept for backward compatibility with code using the old API. It simply calls process_answer from the consolidated implementation. Args: response: The full response text expected_format: Optional expected format type Returns: Dictionary with processed answer information """ return process_answer(response, expected_format) # Configure basic logging for the integration module logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" )