codekingpro/portable-devtools
114k
1from typing import Optional2 3from langchain_core.callbacks import CallbackManagerForToolRun4from langchain_core.tools import BaseTool5from pydantic import Field6 7from langchain_community.utilities.pubmed import PubMedAPIWrapper8 9 10class PubmedQueryRun(BaseTool):11 """Tool that searches the PubMed API."""12 13 name: str = "pub_med"14 description: str = (15 "A wrapper around PubMed. "16 "Useful for when you need to answer questions about medicine, health, "17 "and biomedical topics "18 "from biomedical literature, MEDLINE, life science journals, and online books. "19 "Input should be a search query."20 )21 api_wrapper: PubMedAPIWrapper = Field(default_factory=PubMedAPIWrapper) # type: ignore[arg-type]22 23 def _run(24 self,25 query: str,26 run_manager: Optional[CallbackManagerForToolRun] = None,27 ) -> str:28 """Use the PubMed tool."""29 return self.api_wrapper.run(query)30 