tooluniverse.utils module

tooluniverse.utils.compare_function_calls(pred_function_call, gt_function_call, compare_arguments=True, compare_value=True)[source]
tooluniverse.utils.download_from_hf(tool_config)[source]
tooluniverse.utils.evaluate_function_call(tool_definition, function_call)[source]
tooluniverse.utils.evaluate_function_call_from_toolbox(toolbox, function_call)[source]
tooluniverse.utils.extract_function_call_json(lst, return_message=False, verbose=True, format='llama')[source]
tooluniverse.utils.format_api_response(response_data: Any, format_type: str = 'json') str | Dict[str, Any] | List[Any][source]

Format API response data into a standardized format.

Parameters:
  • response_data (Any) – The response data to format

  • format_type (str) – The desired output format (‘json’, ‘pretty’, ‘minimal’)

Returns:

Formatted response

Return type:

Union[str, Dict[str, Any]]

tooluniverse.utils.get_md5(input_str)[source]
tooluniverse.utils.normalize_gene_symbol(gene_symbol: str) str[source]

Normalize a gene symbol to standard format.

Parameters:

gene_symbol (str) – The gene symbol to normalize

Returns:

Normalized gene symbol

Return type:

str

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.validate_hook_conditions(conditions: Dict[str, Any]) bool[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:

bool

tooluniverse.utils.validate_hook_config(config: Dict[str, Any]) bool[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:

bool

tooluniverse.utils.validate_query(query: Dict[str, Any]) bool[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:

bool

tooluniverse.utils.yaml_to_dict(yaml_file_path)[source]

Convert a YAML file to a dictionary.

Parameters:

yaml_file_path (str) – Path to the YAML file.

Returns:

Dictionary representation of the YAML file content.

Return type:

dict