tooluniverse.europe_pmc_tool 模块

tooluniverse.europe_pmc_tool._normalize_pmcid(pmcid)[源代码]

Return (pmcid_norm, pmcid_digits).

pmcid_norm: “PMC123” form (or None) pmcid_digits: “123” digits only (or None)

tooluniverse.europe_pmc_tool._build_ncbi_pmc_oai_url(pmcid_digits)[源代码]
tooluniverse.europe_pmc_tool._build_ncbi_pmc_efetch_url(pmcid_digits)[源代码]
tooluniverse.europe_pmc_tool._build_ncbi_pmc_html_url(pmcid_norm)[源代码]
tooluniverse.europe_pmc_tool._extract_text_from_html(html_text)[源代码]

Best-effort HTML -> text extraction.

For PMC pages, try to restrict to the main content region to avoid nav/JS/CSS noise.

tooluniverse.europe_pmc_tool._extract_abstract_from_pmc_html(html_text)[源代码]
tooluniverse.europe_pmc_tool._detect_ncbi_oai_error(xml_text)[源代码]
NCBI PMC OAI-PMH often returns HTTP 200 even for logical errors, e.g.:

<error code=”cannotDisseminateFormat”>…</error>

Returns a small structured dict when an error is detected, else None.

tooluniverse.europe_pmc_tool._fetch_fulltext_with_trace(session, *, europe_fulltext_xml_url, pmcid, timeout=20)[源代码]

Fetch full text content with a trace of attempts.

返回:

{

ok: bool, url: str|None, source: str|None, format: “xml”|”html”|None, content_type: str|None, status_code: int|None, content: str|None, trace: list[dict],

}

返回类型:

dict

class tooluniverse.europe_pmc_tool.EuropePMCTool[源代码]

基类:BaseTool

用于在 Europe PMC 上搜索文章及其摘要的工具。

__init__(tool_config, base_url='https://www.ebi.ac.uk/europepmc/webservices/rest/search')[源代码]
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 参数。

_local_name(tag)[源代码]
_extract_abstract_from_fulltext_xml(xml_text)[源代码]
_build_fulltext_xml_url(*, source_db, article_id, pmcid)[源代码]
_build_pmc_oai_url(pmcid)[源代码]

Build an NCBI PMC OAI-PMH URL to retrieve JATS XML for a PMC article.

Europe PMC fullTextXML is not always available even when an article is in PMC. The OAI endpoint provides a robust fallback for extracting full text/abstract.

_fetch_fulltext_with_trace(*, fulltext_url, pmcid, timeout=20)[源代码]
class tooluniverse.europe_pmc_tool.EuropePMCFullTextSnippetsTool[源代码]

基类:BaseTool

Fetch Europe PMC fullTextXML (open access) and return bounded text snippets around user-provided terms. This helps answer questions where the crucial detail is present in the full text (e.g., methods/section titles) but not necessarily in the abstract.

__init__(tool_config)[源代码]
_build_pmc_html_url(pmcid)[源代码]
_build_pmc_oai_url(pmcid)[源代码]
_build_fulltext_xml_url(arguments)[源代码]
_extract_text(xml_text)[源代码]
_extract_text_from_html(html_text)[源代码]
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.europe_pmc_tool.EuropePMCFullTextFetchTool[源代码]

基类:BaseTool

Fetch full text content for a PMC article with deterministic fallbacks and machine-readable provenance (retrieval_trace).

This tool is intended for machine consumption: it always returns a structured status payload and, when successful, includes source/format/content_type.

__init__(tool_config)[源代码]
_build_fulltext_xml_url(arguments)[源代码]
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.europe_pmc_tool.EuropePMCRESTTool[源代码]

基类:BaseTool

Generic REST tool for Europe PMC API endpoints. Supports citations, references, and other article-related endpoints.

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

Build URL from endpoint template and arguments, applying schema defaults for missing path params.

run(arguments)[源代码]

Execute the Europe PMC REST API request.

class tooluniverse.europe_pmc_tool.EuropePMCStructuredFullTextTool[源代码]

基类:BaseTool

Retrieve and parse full-text XML from Europe PMC into structured sections (title, abstract, introduction, methods, results, discussion, figures, tables, references). Accepts a PMC ID or PMID (auto-resolved via the Europe PMC search API).

_SECTION_KEYWORDS: dict[str, list[str]] = {'acknowledgments': ['acknowledgments', 'acknowledgements', 'funding'], 'conclusions': ['conclusions', 'conclusion', 'summary'], 'discussion': ['discussion'], 'introduction': ['introduction', 'background', 'intro'], 'methods': ['methods', 'materials and methods', 'material and methods', 'methodology', 'experimental', 'experimental procedures', 'study design', 'patients and methods'], 'results': ['results', 'findings']}
__init__(tool_config)[源代码]
static _local(tag)[源代码]

Strip XML namespace prefix.

static _itertext(el)[源代码]

Collapse all text under el into a single whitespace-normalised string.

_resolve_pmid_to_pmcid(pmid)[源代码]

Use Europe PMC search to convert a PMID to a PMCID.

_classify_section(title_text)[源代码]

Map a section title to a canonical name, or return ‘other’.

_parse_article_xml(xml_text)[源代码]

Parse JATS/NLM article XML into structured sections.

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 参数。