Source code for

"""Tool for the SemanticScholar API."""

from typing import Optional, Type

from langchain_core.callbacks import CallbackManagerForToolRun
from langchain_core.pydantic_v1 import BaseModel, Field
from import BaseTool

from langchain_community.utilities.semanticscholar import SemanticScholarAPIWrapper

[docs]class SemantscholarInput(BaseModel): """Input for the SemanticScholar tool.""" query: str = Field(description="search query to look up")
[docs]class SemanticScholarQueryRun(BaseTool): """Tool that searches the semanticscholar API.""" name: str = "semanticscholar" description: str = ( "A wrapper around " "Useful for when you need to answer to questions" "from research papers." "Input should be a search query." ) api_wrapper: SemanticScholarAPIWrapper = Field( default_factory=SemanticScholarAPIWrapper # type: ignore[arg-type] ) args_schema: Type[BaseModel] = SemantscholarInput def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the Semantic Scholar tool.""" return