tooluniverse.semantic_scholar_tool 模块

class tooluniverse.semantic_scholar_tool.SemanticScholarTool[源代码]

基类:BaseTool

用于在 Semantic Scholar 上搜索论文及其摘要的工具。

API key is read from environment variable SEMANTIC_SCHOLAR_API_KEY. Request an API key at: https://www.semanticscholar.org/product/api

Rate limits: - Without API key: 1 request/second - With API key: 100 requests/second

_last_request_time = 0.0
_rate_limit_lock = <unlocked _thread.lock object>
__init__(tool_config, base_url='https://api.semanticscholar.org/graph/v1/paper/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 参数。

_enforce_rate_limit(has_api_key)[源代码]
_fetch_missing_abstract(paper_id)[源代码]
class tooluniverse.semantic_scholar_tool.SemanticScholarPDFSnippetsTool[源代码]

基类:BaseTool

Fetch a paper’s PDF from Semantic Scholar and return bounded text snippets around user-provided terms. Uses markitdown to convert PDF to markdown text.

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