tooluniverse.openfda_tool 模块¶
- tooluniverse.openfda_tool._get_drug_names_query()[源代码]¶
Get the GraphQL query for drug names (cached)
- tooluniverse.openfda_tool._execute_opentargets_query(chembl_id)[源代码]¶
Directly execute OpenTargets GraphQL query (most efficient)
- tooluniverse.openfda_tool.extract_nested_fields(records, fields, keywords=None)[源代码]¶
递归提取字典列表中的嵌套字段。
- 参数:
records – 用于提取字段的字典列表
fields – 要提取的嵌套字段列表,每个字段均以点表示法指定(例如,’openfda.brand_name’)
- 返回:
仅包含指定字段的字典列表
- tooluniverse.openfda_tool.map_properties_to_openfda_fields(arguments, search_fields)[源代码]¶
根据 search_fields 映射,将提供的参数映射到相应的 openFDA 字段。
- 参数:
arguments – 包含属性名称和值的输入参数。
search_fields – 属性名称与 openFDA 字段的映射。
- 返回:
一个包含openFDA字段及其对应值的字典。
- tooluniverse.openfda_tool.extract_sentences_with_keywords(text_list, keywords)[源代码]¶
从文本中提取包含任何指定关键词的句子。
Parameters - text (str): The input text from which to extract sentences. - keywords (list): A list of keywords to search for in the text.
Returns - list: A list of sentences containing any of the keywords.
- tooluniverse.openfda_tool.search_openfda(params=None, endpoint_url=None, api_key=None, sort=None, limit=5, skip=None, count=None, exists=None, return_fields=None, exist_option='OR', search_keyword_option='AND', keywords_filter=True)[源代码]¶
- class tooluniverse.openfda_tool.FDATool[源代码]¶
基类:
BaseTool- 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 参数。
- class tooluniverse.openfda_tool.FDADrugLabelSearchTool[源代码]¶
基类:
FDATool- 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 参数。
- class tooluniverse.openfda_tool.FDADrugLabelSearchIDTool[源代码]¶
基类:
FDATool- 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 参数。
- class tooluniverse.openfda_tool.FDADrugLabelFieldValueTool[源代码]¶
基类:
BaseToolSearch the openFDA drug label dataset by specifying a single openFDA field (e.g., “openfda.generic_name”) and a corresponding field_value.
This tool is intentionally generic and does not modify any existing FDA tools.
- 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 参数。
- class tooluniverse.openfda_tool.FDADrugLabelGetDrugNamesByIndicationAggregated[源代码]¶
-
Enhanced version of FDA_get_drug_names_by_indication that: - Iterates through all results in batches of 100 (no limit) - Aggregates results by generic name - Returns one entry per generic name with indication and all brand names
- run(arguments)[源代码]¶
Run the aggregated drug names search by indication.
Iterates through all results in batches of 100, aggregates by generic name, and returns a list where each entry contains: - generic_name: The generic drug name - indication: The indication (from input) - brand_names: List of all brand names for this generic name
- class tooluniverse.openfda_tool.FDADrugLabelGetDrugNamesByIndicationStats[源代码]¶
-
Enhanced version using FDA count API to efficiently aggregate drug names by indication. Uses count mechanism to get brand_name and generic_name distributions without fetching full records.
- class tooluniverse.openfda_tool.OpenFDADrugEventsTool[源代码]¶
基类:
BaseRESTToolOpenFDA drug adverse event search with convenience parameters.
Accepts either a raw Lucene ‘search’ string or the convenience parameters ‘drug_name’ and ‘reaction’ (which are assembled into a Lucene query).
Note: MedDRA terms in FAERS use British English spelling (e.g. ‘haemorrhage’ not ‘hemorrhage’, ‘haematoma’ not ‘hematoma’).
- _VALID_API_PARAMS = frozenset({'api_key', 'count', 'limit', 'search', 'skip'})¶