tooluniverse.utils module¶
- tooluniverse.utils.get_user_cache_dir()[source]¶
Return a cross-platform user cache directory for ToolUniverse.
macOS: ~/Library/Caches/ToolUniverse Linux: $XDG_CACHE_HOME or ~/.cache/tooluniverse Windows: %LOCALAPPDATA%ToolUniverseCache
- tooluniverse.utils.read_json_list(file_path)[source]¶
Reads a list of JSON objects from a file.
Parameters: file_path (str): The path to the JSON file.
Returns: list: A list of dictionaries containing the JSON objects.
- tooluniverse.utils.compare_function_calls(pred_function_call, gt_function_call, compare_arguments=True, compare_value=True)[source]¶
- tooluniverse.utils.extract_function_call_json(lst, return_message=False, verbose=True, format='llama')[source]¶
- tooluniverse.utils.format_error_response(error, tool_name=None, context=None)[source]¶
Format error responses in a consistent structure.
This function ensures all error responses follow the same format for better error handling and debugging.
- tooluniverse.utils.get_parameter_schema(tool_config)[source]¶
Get parameter schema from tool configuration.
- Parameters:
tool_config (
Dict[str, Any]
) – Tool configuration dictionary- Returns:
Parameter schema dictionary
- Return type:
Dict[str, Any]
- tooluniverse.utils.validate_query(query)[source]¶
Validate a query dictionary for required fields and structure.
- Parameters:
query (
Dict[str, Any]
) – The query dictionary to validate- Returns:
True if query is valid, False otherwise
- Return type:
- tooluniverse.utils.normalize_gene_symbol(gene_symbol)[source]¶
Normalize a gene symbol to standard format.
- tooluniverse.utils.format_api_response(response_data, format_type='json')[source]¶
Format API response data into a standardized format.
- tooluniverse.utils.validate_hook_config(config)[source]¶
Validate hook configuration for correctness and completeness.
This function checks that the hook configuration contains all required fields and that the structure is valid for the hook system.
- Parameters:
config (
Dict[str, Any]
) – Hook configuration to validate- Returns:
True if configuration is valid, False otherwise
- Return type:
- tooluniverse.utils.validate_hook_conditions(conditions)[source]¶
Validate hook trigger conditions.
This function checks that the hook conditions are properly structured and contain valid operators and thresholds.
- Parameters:
conditions (
Dict[str, Any]
) – Hook conditions to validate- Returns:
True if conditions are valid, False otherwise
- Return type: