|
""" |
|
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 |
|
|
|
|
|
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") |
|
|
|
|
|
__all__ = [ |
|
|
|
'setup_logging', |
|
'safe_execute', |
|
'get_nested_value', |
|
'set_nested_value', |
|
'load_file_content', |
|
'load_json_file', |
|
'validate_api_key', |
|
'format_error_message', |
|
|
|
|
|
'load_from_env', |
|
'load_from_file', |
|
'load_from_env_file', |
|
'merge_configs', |
|
'find_config_file', |
|
'get_config_value', |
|
'convert_value_type', |
|
|
|
|
|
'FORMAT_TYPES', |
|
'extract_answer', |
|
'extract_number', |
|
'extract_date', |
|
'extract_boolean', |
|
'extract_list', |
|
'extract_entity', |
|
'extract_structured_data', |
|
'format_answer', |
|
'validate_answer_format', |
|
'process_answer', |
|
|
|
|
|
'format_response' |
|
] |
|
|
|
|
|
|
|
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) |
|
|
|
|
|
logging.basicConfig( |
|
level=logging.INFO, |
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" |
|
) |