Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Add PubMed to tools (#2652)
crazywoolab5c1bb346c99
diff --git a/api/core/tools/provider/_position.yaml b/api/core/tools/provider/_position.yamlindex 40c62d710a0..109c10c34b8 100644--- a/api/core/tools/provider/_position.yaml+++ b/api/core/tools/provider/_position.yaml@@ -1,16 +1,19 @@- bing+- duckduckgo+- yahoo- wikipedia+- arxiv+- pubmed- dalle- azuredalle+- stablediffusion- webscraper+- youtube- wolframalpha+- maths- github- chart- time-- yahoo-- stablediffusion- vectorizer-- youtube- gaode-- mathsdiff --git a/api/core/tools/provider/builtin/pubmed/_assets/icon.svg b/api/core/tools/provider/builtin/pubmed/_assets/icon.svgnew file mode 100644index 00000000000..6d6ff593f0c--- /dev/null+++ b/api/core/tools/provider/builtin/pubmed/_assets/icon.svg@@ -0,0 +1 @@+<svg height="512" viewBox="0 0 448 512" width="448" xmlns="http://www.w3.org/2000/svg"><path d="m48 32c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-352c0-26.5-21.5-48-48-48zm69.56445 64s49.09165 11.12539 46.59571 94.78125c0 0 41.47034-117.171493 204.5664 1.64844 0 42.78788-.31445 172.24246-.31445 223.57031-176.89733-149.87989-207.38477-22.06836-207.38477-22.06836 0-79.8558-81.753902-70.33984-81.753902-70.33984v-212.65039s18.755175 1.4021 38.291012 11.11132zm86.14649 98.2832-24.00196 141.34961h36.5625l11.81446-81.3789h.37304l32.44727 81.3789h14.63281l33.93946-81.3789h.37304l10.31446 81.3789h36.7832l-21.40234-141.34961h-36.5625l-30.38868 75.54102-28.69531-75.54102z"/></svg>\ No newline at end of filediff --git a/api/core/tools/provider/builtin/pubmed/pubmed.py b/api/core/tools/provider/builtin/pubmed/pubmed.pynew file mode 100644index 00000000000..663617c0c18--- /dev/null+++ b/api/core/tools/provider/builtin/pubmed/pubmed.py@@ -0,0 +1,20 @@+from core.tools.errors import ToolProviderCredentialValidationError+from core.tools.provider.builtin.pubmed.tools.pubmed_search import PubMedSearchTool+from core.tools.provider.builtin_tool_provider import BuiltinToolProviderController+++class PubMedProvider(BuiltinToolProviderController):+ def _validate_credentials(self, credentials: dict) -> None:+ try:+ PubMedSearchTool().fork_tool_runtime(+ meta={+ "credentials": credentials,+ }+ ).invoke(+ user_id='',+ tool_parameters={+ "query": "John Doe",+ },+ )+ except Exception as e:+ raise ToolProviderCredentialValidationError(str(e))\ No newline at end of filediff --git a/api/core/tools/provider/builtin/pubmed/pubmed.yaml b/api/core/tools/provider/builtin/pubmed/pubmed.yamlnew file mode 100644index 00000000000..971a6fb204f--- /dev/null+++ b/api/core/tools/provider/builtin/pubmed/pubmed.yaml@@ -0,0 +1,10 @@+identity:+ author: Pink Banana+ name: pubmed+ label:+ en_US: PubMed+ zh_Hans: PubMed+ description:+ en_US: A search engine for biomedical literature.+ zh_Hans: 一款生物医学文献搜索引擎。+ icon: icon.svgdiff --git a/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.py b/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.pynew file mode 100644index 00000000000..1bed1fa77c2--- /dev/null+++ b/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.py@@ -0,0 +1,40 @@+from typing import Any++from langchain.tools import PubmedQueryRun+from pydantic import BaseModel, Field++from core.tools.entities.tool_entities import ToolInvokeMessage+from core.tools.tool.builtin_tool import BuiltinTool+++class PubMedInput(BaseModel):+ query: str = Field(..., description="Search query.")+++class PubMedSearchTool(BuiltinTool):+ """+ Tool for performing a search using PubMed search engine.+ """++ def _invoke(self, user_id: str, tool_parameters: dict[str, Any]) -> ToolInvokeMessage | list[ToolInvokeMessage]:+ """+ Invoke the PubMed search tool.++ Args:+ user_id (str): The ID of the user invoking the tool.+ tool_parameters (dict[str, Any]): The parameters for the tool invocation.++ Returns:+ ToolInvokeMessage | list[ToolInvokeMessage]: The result of the tool invocation.+ """+ query = tool_parameters.get('query', '')++ if not query:+ return self.create_text_message('Please input query')++ tool = PubmedQueryRun(args_schema=PubMedInput)++ result = tool.run(query)++ return self.create_text_message(self.summary(user_id=user_id, content=result))+\ No newline at end of filediff --git a/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.yaml b/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.yamlnew file mode 100644index 00000000000..77ab809fbc3--- /dev/null+++ b/api/core/tools/provider/builtin/pubmed/tools/pubmed_search.yaml@@ -0,0 +1,23 @@+identity:+ name: pubmed_search+ author: Pink Banana+ label:+ en_US: PubMed Search+ zh_Hans: PubMed 搜索+description:+ human:+ en_US: PubMed® comprises more than 35 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full text content from PubMed Central and publisher web sites.+ zh_Hans: PubMed® 包含来自 MEDLINE、生命科学期刊和在线书籍的超过 3500 万篇生物医学文献引用。引用可能包括来自 PubMed Central 和出版商网站的全文内容链接。+ llm: Perform searches on PubMed and get results.+parameters:+ - name: query+ type: string+ required: true+ label:+ en_US: Query string+ zh_Hans: 查询语句+ human_description:+ en_US: The search query.+ zh_Hans: 搜索查询语句。+ llm_description: Key words for searching+ form: llm