self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any    ) -> Any:        """Run when LLM errors."""    def on_chain_start(        self, serialized: Dict[str, Any], inputs: Dict[str, Any], **kwargs: Any    ) -> Any:        print(f"on_chain_start {serialized['name']}")    def on_tool_start(        self, serialized: Dict[str, Any], input_str: str, **kwargs: Any    ) -> Any:        print(f"on_tool_start {serialized['name']}")    def on_agent_action(self, action: AgentAction, **kwargs: Any) -> Any:        print(f"on_agent_action {action}")class MyCustomHandlerTwo(BaseCallbackHandler):    def on_llm_start(        self, serialized: Dict[str, Any], prompts: List[str], **kwargs: Any    ) -> Any:        print(f"on_llm_start (I'm the second handler!!) {serialized['name']}")# Instantiate the handlershandler1 = MyCustomHandlerOne()handler2 = MyCustomHandlerTwo()# Setup the agent. Only the `llm` will issue callbacks for handler2llm = OpenAI(temperature=0, streaming=True, callbacks=[handler2])tools = load_tools(["llm-math"], llm=llm)agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION)# Callbacks for handler1 will be issued by every object involved in the# Agent execution (llm, llmchain, tool, agent executor)agent.run("What is 2 raised to the 0.235 power?", callbacks=[handler1])    on_chain_start AgentExecutor    on_chain_start LLMChain    on_llm_start OpenAI    on_llm_start (I'm the second handler!!) OpenAI    on_new_token  I    on_new_token  need    on_new_token  to    on_new_token  use    on_new_token  a    on_new_token  calculator    on_new_token  to    on_new_token  solve    on_new_token  this    on_new_token .    on_new_token     Action    on_new_token :    on_new_token  Calculator    on_new_token     Action    on_new_token  Input    on_new_token :    on_new_token  2    on_new_token ^    on_new_token 0    on_new_token .    on_new_token 235    on_new_token     on_agent_action AgentAction(tool='Calculator', tool_input='2^0.235',
In the previous examples, we passed in callback handlers upon creation of an object by using callbacks=. In this case, the callbacks will be scoped to that particular object.
In the previous examples, we passed in callback handlers upon creation of an object by using callbacks=. In this case, the callbacks will be scoped to that particular object. ->: self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any    ) -> Any:        """Run when LLM errors."""    def on_chain_start(        self, serialized: Dict[str, Any], inputs: Dict[str, Any], **kwargs: Any    ) -> Any:        print(f"on_chain_start {serialized['name']}")    def on_tool_start(        self, serialized: Dict[str, Any], input_str: str, **kwargs: Any    ) -> Any:        print(f"on_tool_start {serialized['name']}")    def on_agent_action(self, action: AgentAction, **kwargs: Any) -> Any:        print(f"on_agent_action {action}")class MyCustomHandlerTwo(BaseCallbackHandler):    def on_llm_start(        self, serialized: Dict[str, Any], prompts: List[str], **kwargs: Any    ) -> Any:        print(f"on_llm_start (I'm the second handler!!) {serialized['name']}")# Instantiate the handlershandler1 = MyCustomHandlerOne()handler2 = MyCustomHandlerTwo()# Setup the agent. Only the `llm` will issue callbacks for handler2llm = OpenAI(temperature=0, streaming=True, callbacks=[handler2])tools = load_tools(["llm-math"], llm=llm)agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION)# Callbacks for handler1 will be issued by every object involved in the# Agent execution (llm, llmchain, tool, agent executor)agent.run("What is 2 raised to the 0.235 power?", callbacks=[handler1])    on_chain_start AgentExecutor    on_chain_start LLMChain    on_llm_start OpenAI    on_llm_start (I'm the second handler!!) OpenAI    on_new_token  I    on_new_token  need    on_new_token  to    on_new_token  use    on_new_token  a    on_new_token  calculator    on_new_token  to    on_new_token  solve    on_new_token  this    on_new_token .    on_new_token     Action    on_new_token :    on_new_token  Calculator    on_new_token     Action    on_new_token  Input    on_new_token :    on_new_token  2    on_new_token ^    on_new_token 0    on_new_token .    on_new_token 235    on_new_token     on_agent_action AgentAction(tool='Calculator', tool_input='2^0.235',