tooluniverse.ctg_tool module¶

class tooluniverse.ctg_tool.ClinicalTrialsTool[source]¶

Bases: RESTfulTool

__init__(tool_config)[source]¶
_map_param_names(arguments)[source]¶

Maps the parameter names in the arguments dictionary to the expected parameter names defined in the tool’s JSON configuration.

Parameters:

arguments (dict) – Runtime arguments provided to the tool’s run method.

Returns:

A new dictionary with mapped parameter names.

Return type:

dict

_prepare_api_params(arguments)[source]¶

Prepares the dictionary of parameters for the API query string based on tool config and runtime arguments.

Parameters:

arguments (dict) – Runtime arguments provided to the tool’s run method.

Returns:

A dictionary of parameters ready for the API requests.

Return type:

dict

_format_endpoint_url(arguments)[source]¶

Formats the endpoint URL by substituting path parameters (like {nctId}) with values from the arguments dictionary.

Parameters:

arguments (dict) – Runtime arguments provided to the tool’s run method.

Returns:

The formatted endpoint URL.

Return type:

str

run(arguments)[source]¶

Execute the tool.

The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.

Parameters:
  • arguments (dict, optional) – Tool-specific arguments

  • stream_callback (callable, optional) – Callback for streaming responses

  • use_cache (bool, optional) – Whether result caching is enabled

  • validate (bool, optional) – Whether parameter validation was performed

Note

These additional parameters (stream_callback, use_cache, validate) are passed from run_one_function() to provide context about the execution. Tools can use these for optimization or special handling.

For backward compatibility, tools that don’t accept these parameters will still work - they will only receive the arguments parameter.

class tooluniverse.ctg_tool.ClinicalTrialsSearchTool[source]¶

Bases: ClinicalTrialsTool

__init__(tool_config)[source]¶
run(arguments)[source]¶

Executes the search query for clinical trials.

Parameters:

arguments (dict) – A dictionary containing parameters provided by the user/LLM

Returns:

The JSON response from the API as a dictionary,

or raw text for non-JSON responses, or an error dictionary.

Return type:

dict or str

_simplify_output(response)[source]¶
class tooluniverse.ctg_tool.ClinicalTrialsDetailsTool[source]¶

Bases: ClinicalTrialsTool

__init__(tool_config)[source]¶
run(arguments)[source]¶

Execute the tool.

The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.

Parameters:
  • arguments (dict, optional) – Tool-specific arguments

  • stream_callback (callable, optional) – Callback for streaming responses

  • use_cache (bool, optional) – Whether result caching is enabled

  • validate (bool, optional) – Whether parameter validation was performed

Note

These additional parameters (stream_callback, use_cache, validate) are passed from run_one_function() to provide context about the execution. Tools can use these for optimization or special handling.

For backward compatibility, tools that don’t accept these parameters will still work - they will only receive the arguments parameter.

_simplify_output(study, query_type)[source]¶

Manually extract generally most useful information

_extract_outcomes_from_output(study, outcome_measure)[source]¶
_extract_safety_from_output(study, organs, adverse_event_type)[source]¶
_remove_empty_values(obj)[source]¶