tooluniverse.ctg_tool module

class tooluniverse.ctg_tool.ClinicalTrialsTool[source]

Bases: RESTfulTool

_BASE_URL = 'https://clinicaltrials.gov/api/v2'
_OPERATION_URLS = {'field_values': '/stats/field-values', 'get_study': '/studies', 'search': '/studies', 'stats_size': '/stats/size'}
__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

dict: A new dictionary with mapped parameter names.

_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

dict: A dictionary of parameters ready for the API requests.

_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

str: The formatted endpoint URL.

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.

Handle search operations (search_studies, search_by_intervention, search_by_sponsor).

_run_get_study(arguments)[source]

Get full details for a single study by NCT ID.

_run_stats_size(arguments)[source]

Get aggregate ClinicalTrials.gov database statistics.

_run_field_values(arguments)[source]

Get value distribution for a specific field.

_cached_version_hash: str | None
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
dict or str: The JSON response from the API as a dictionary,

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

_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]