the BaseTool class.StructuredTool dataclass‚ÄãTo dynamically generate a structured tool from a given function, the fastest way to get started is with StructuredTool.from_function().import requestsfrom langchain.tools import StructuredTooldef post_message(url: str, body: dict, parameters: Optional[dict] = None) -> str:    """Sends a POST request to the given url with the given body and parameters."""    result = requests.post(url, json=body, params=parameters)    return f"Status: {result.status_code} - {result.text}"tool = StructuredTool.from_function(post_message)Subclassing the BaseTool‚ÄãThe BaseTool automatically infers the schema from the _run method's signature.from typing import Optional, Typefrom langchain.callbacks.manager import (    AsyncCallbackManagerForToolRun,    CallbackManagerForToolRun,)class CustomSearchTool(BaseTool):    name = "custom_search"    description = "useful for when you need to answer questions about current events"    def _run(        self,        query: str,        engine: str = "google",        gl: str = "us",        hl: str = "en",        run_manager: Optional[CallbackManagerForToolRun] = None,    ) -> str:        """Use the tool."""        search_wrapper = SerpAPIWrapper(params={"engine": engine, "gl": gl, "hl": hl})        return search_wrapper.run(query)    async def _arun(        self,        query: str,        engine: str = "google",        gl: str = "us",        hl: str = "en",        run_manager: Optional[AsyncCallbackManagerForToolRun] = None,    ) -> str:        """Use the tool asynchronously."""        raise NotImplementedError("custom_search does not support async")# You can provide a custom args schema to add descriptions or custom validationclass SearchSchema(BaseModel):    query: str = Field(description="should be a search query")    engine: str = Field(description="should be a search engine")    gl: str = Field(description="should be a country code")    hl: str = Field(description="should be a language code")class
When constructing your own agent, you will need to provide it with a list of Tools that it can use. Besides the actual function that is called, the Tool consists of several components:
When constructing your own agent, you will need to provide it with a list of Tools that it can use. Besides the actual function that is called, the Tool consists of several components: ->: the BaseTool class.StructuredTool dataclass‚ÄãTo dynamically generate a structured tool from a given function, the fastest way to get started is with StructuredTool.from_function().import requestsfrom langchain.tools import StructuredTooldef post_message(url: str, body: dict, parameters: Optional[dict] = None) -> str:    """Sends a POST request to the given url with the given body and parameters."""    result = requests.post(url, json=body, params=parameters)    return f"Status: {result.status_code} - {result.text}"tool = StructuredTool.from_function(post_message)Subclassing the BaseTool‚ÄãThe BaseTool automatically infers the schema from the _run method's signature.from typing import Optional, Typefrom langchain.callbacks.manager import (    AsyncCallbackManagerForToolRun,    CallbackManagerForToolRun,)class CustomSearchTool(BaseTool):    name = "custom_search"    description = "useful for when you need to answer questions about current events"    def _run(        self,        query: str,        engine: str = "google",        gl: str = "us",        hl: str = "en",        run_manager: Optional[CallbackManagerForToolRun] = None,    ) -> str:        """Use the tool."""        search_wrapper = SerpAPIWrapper(params={"engine": engine, "gl": gl, "hl": hl})        return search_wrapper.run(query)    async def _arun(        self,        query: str,        engine: str = "google",        gl: str = "us",        hl: str = "en",        run_manager: Optional[AsyncCallbackManagerForToolRun] = None,    ) -> str:        """Use the tool asynchronously."""        raise NotImplementedError("custom_search does not support async")# You can provide a custom args schema to add descriptions or custom validationclass SearchSchema(BaseModel):    query: str = Field(description="should be a search query")    engine: str = Field(description="should be a search engine")    gl: str = Field(description="should be a country code")    hl: str = Field(description="should be a language code")class