1.086734862526058'Handling Tool Errors‚ÄãWhen a tool encounters an error and the exception is not caught, the agent will stop executing. If you want the agent to continue execution, you can raise a ToolException and set handle_tool_error accordingly. When ToolException is thrown, the agent will not stop working, but will handle the exception according to the handle_tool_error variable of the tool, and the processing result will be returned to the agent as observation, and printed in red.You can set handle_tool_error to True, set it a unified string value, or set it as a function. If it's set as a function, the function should take a ToolException as a parameter and return a str value.Please note that only raising a ToolException won't be effective. You need to first set the handle_tool_error of the tool because its default value is False.from langchain.tools.base import ToolExceptionfrom langchain.utilities import SerpAPIWrapperfrom langchain.agents import AgentType, initialize_agentfrom langchain.chat_models import ChatOpenAIfrom langchain.tools import Toolfrom langchain.chat_models import ChatOpenAIdef _handle_error(error: ToolException) -> str:    return (        "The following errors occurred during tool execution:"        + error.args[0]        + "Please try another tool."    )def search_tool1(s: str):    raise ToolException("The search tool1 is not available.")def search_tool2(s: str):    raise ToolException("The search tool2 is not available.")search_tool3 = SerpAPIWrapper()description = "useful for when you need to answer questions about current events.You should give priority to using it."tools = [    Tool.from_function(        func=search_tool1,        name="Search_tool1",        description=description,        handle_tool_error=True,    ),    Tool.from_function(        func=search_tool2,        name="Search_tool2",        description=description,        handle_tool_error=_handle_error,    ),    Tool.from_function(        func=search_tool3.run,
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: ->: 1.086734862526058'Handling Tool Errors‚ÄãWhen a tool encounters an error and the exception is not caught, the agent will stop executing. If you want the agent to continue execution, you can raise a ToolException and set handle_tool_error accordingly. When ToolException is thrown, the agent will not stop working, but will handle the exception according to the handle_tool_error variable of the tool, and the processing result will be returned to the agent as observation, and printed in red.You can set handle_tool_error to True, set it a unified string value, or set it as a function. If it's set as a function, the function should take a ToolException as a parameter and return a str value.Please note that only raising a ToolException won't be effective. You need to first set the handle_tool_error of the tool because its default value is False.from langchain.tools.base import ToolExceptionfrom langchain.utilities import SerpAPIWrapperfrom langchain.agents import AgentType, initialize_agentfrom langchain.chat_models import ChatOpenAIfrom langchain.tools import Toolfrom langchain.chat_models import ChatOpenAIdef _handle_error(error: ToolException) -> str:    return (        "The following errors occurred during tool execution:"        + error.args[0]        + "Please try another tool."    )def search_tool1(s: str):    raise ToolException("The search tool1 is not available.")def search_tool2(s: str):    raise ToolException("The search tool2 is not available.")search_tool3 = SerpAPIWrapper()description = "useful for when you need to answer questions about current events.You should give priority to using it."tools = [    Tool.from_function(        func=search_tool1,        name="Search_tool1",        description=description,        handle_tool_error=True,    ),    Tool.from_function(        func=search_tool2,        name="Search_tool2",        description=description,        handle_tool_error=_handle_error,    ),    Tool.from_function(        func=search_tool3.run,