tooluniverse.ctg_tool 模块

class tooluniverse.ctg_tool.ClinicalTrialsTool[源代码]

基类: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)[源代码]
_map_param_names(arguments)[源代码]

将参数字典中的参数名称映射到工具 JSON 配置中定义的预期参数名称。

参数:

arguments (dict) – 传递给工具 run 方法的运行时参数。

返回值

dict: A new dictionary with mapped parameter names.

_prepare_api_params(arguments)[源代码]

根据工具配置和运行时参数准备用于 API 查询字符串的参数字典。

参数:

arguments (dict) – 传递给工具 run 方法的运行时参数。

返回值

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

_format_endpoint_url(arguments)[源代码]

通过将路径参数(例如 {nctId})替换为参数字典中的值来格式化端点 URL。

参数:

arguments (dict) – 传递给工具 run 方法的运行时参数。

返回值

str: The formatted endpoint URL.

run(arguments)[源代码]

执行该工具。

默认的 BaseTool 实现接受一个可选的参数映射,以便与大多数具体工具实现保持一致,这些工具通常需要一个输入字典。

参数:
  • arguments (dict, optional) – 工具专用参数

  • stream_callback (callable, optional) – 用于流式响应的回调

  • use_cache (bool, optional) – 是否启用了结果缓存

  • validate (bool, optional) – 是否已执行参数验证

备注

这些附加参数(stream_callback、use_cache、validate)由 run_one_function() 传递,用于提供有关执行的上下文。工具可以利用这些参数进行优化或特殊处理。

为了向后兼容,不支持这些参数的工具仍然可以正常运行——它们将只接收 arguments 参数。

Handle search operations (search_studies, search_by_intervention, search_by_sponsor).

_run_get_study(arguments)[源代码]

Get full details for a single study by NCT ID.

_run_stats_size(arguments)[源代码]

Get aggregate ClinicalTrials.gov database statistics.

_run_field_values(arguments)[源代码]

Get value distribution for a specific field.

_cached_version_hash: str | None
class tooluniverse.ctg_tool.ClinicalTrialsSearchTool[源代码]

基类:ClinicalTrialsTool

__init__(tool_config)[源代码]
run(arguments)[源代码]

执行临床试验的搜索查询。

参数:

arguments (dict) – 一个包含用户或LLM提供的参数的字典

返回值
dict or str: The JSON response from the API as a dictionary,

或非 JSON 响应的原始文本,或错误字典。

_simplify_output(response)[源代码]
class tooluniverse.ctg_tool.ClinicalTrialsDetailsTool[源代码]

基类:ClinicalTrialsTool

__init__(tool_config)[源代码]
run(arguments)[源代码]

执行该工具。

默认的 BaseTool 实现接受一个可选的参数映射,以便与大多数具体工具实现保持一致,这些工具通常需要一个输入字典。

参数:
  • arguments (dict, optional) – 工具专用参数

  • stream_callback (callable, optional) – 用于流式响应的回调

  • use_cache (bool, optional) – 是否启用了结果缓存

  • validate (bool, optional) – 是否已执行参数验证

备注

这些附加参数(stream_callback、use_cache、validate)由 run_one_function() 传递,用于提供有关执行的上下文。工具可以利用这些参数进行优化或特殊处理。

为了向后兼容,不支持这些参数的工具仍然可以正常运行——它们将只接收 arguments 参数。

_simplify_output(study, query_type)[源代码]

手动提取通常最有用的信息

_extract_outcomes_from_output(study, outcome_measure)[源代码]
_extract_safety_from_output(study, organs, adverse_event_type)[源代码]
_remove_empty_values(obj)[源代码]