Source code for

from typing import List, Optional, Type

from langchain_core.callbacks import (
from langchain_core.documents import Document
from langchain_core.pydantic_v1 import BaseModel, Field
from import BaseTool

from import YouSearchAPIWrapper

[docs]class YouInput(BaseModel): """Input schema for the tool.""" query: str = Field(description="should be a search query")
[docs]class YouSearchTool(BaseTool): """Tool that searches the API.""" name = "you_search" description = ( "The YOU APIs make LLMs and search experiences more factual and" "up to date with realtime web data." ) args_schema: Type[BaseModel] = YouInput api_wrapper: YouSearchAPIWrapper = Field(default_factory=YouSearchAPIWrapper) def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> List[Document]: """Use the tool.""" return self.api_wrapper.results(query) async def _arun( self, query: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> List[Document]: """Use the tool asynchronously.""" return await self.api_wrapper.results_async(query)