the StdOutCallbackHandler when initializing our chainchain = LLMChain(llm=llm, prompt=prompt, callbacks=[handler])chain.run(number=2)# Use verbose flag: Then, let's use the `verbose` flag to achieve the same resultchain = LLMChain(llm=llm, prompt=prompt, verbose=True)chain.run(number=2)# Request callbacks: Finally, let's use the request `callbacks` to achieve the same resultchain = LLMChain(llm=llm, prompt=prompt)chain.run(number=2, callbacks=[handler])    > Entering new LLMChain chain...    Prompt after formatting:    1 + 2 =    > Finished chain.    > Entering new LLMChain chain...    Prompt after formatting:    1 + 2 =    > Finished chain.    > Entering new LLMChain chain...    Prompt after formatting:    1 + 2 =    > Finished chain.    '\n\n3'Where to pass in callbacks‚ÄãThe callbacks argument is available on most objects throughout the API (Chains, Models, Tools, Agents, etc.) in two different places:Constructor callbacks: defined in the constructor, e.g. LLMChain(callbacks=[handler], tags=['a-tag']), which will be used for all calls made on that object, and will be scoped to that object only, e.g. if you pass a handler to the LLMChain constructor, it will not be used by the Model attached to that chain.Request callbacks: defined in the run()/apply() methods used for issuing a request, e.g. chain.run(input, callbacks=[handler]), which will be used for that specific request only, and all sub-requests that it contains (e.g. a call to an LLMChain triggers a call to a Model, which uses the same handler passed in the call() method).The verbose argument is available on most objects throughout the API (Chains, Models, Tools, Agents, etc.) as a constructor argument, e.g. LLMChain(verbose=True), and it is equivalent to passing a ConsoleCallbackHandler to the callbacks argument of that object and all child objects. This is useful for debugging, as it will log all events to the console.When do you want to use each of these?‚ÄãConstructor callbacks are most useful for use
Head to Integrations for documentation on built-in callbacks integrations with 3rd-party tools.
Head to Integrations for documentation on built-in callbacks integrations with 3rd-party tools. ->: the StdOutCallbackHandler when initializing our chainchain = LLMChain(llm=llm, prompt=prompt, callbacks=[handler])chain.run(number=2)# Use verbose flag: Then, let's use the `verbose` flag to achieve the same resultchain = LLMChain(llm=llm, prompt=prompt, verbose=True)chain.run(number=2)# Request callbacks: Finally, let's use the request `callbacks` to achieve the same resultchain = LLMChain(llm=llm, prompt=prompt)chain.run(number=2, callbacks=[handler])    > Entering new LLMChain chain...    Prompt after formatting:    1 + 2 =    > Finished chain.    > Entering new LLMChain chain...    Prompt after formatting:    1 + 2 =    > Finished chain.    > Entering new LLMChain chain...    Prompt after formatting:    1 + 2 =    > Finished chain.    '\n\n3'Where to pass in callbacks‚ÄãThe callbacks argument is available on most objects throughout the API (Chains, Models, Tools, Agents, etc.) in two different places:Constructor callbacks: defined in the constructor, e.g. LLMChain(callbacks=[handler], tags=['a-tag']), which will be used for all calls made on that object, and will be scoped to that object only, e.g. if you pass a handler to the LLMChain constructor, it will not be used by the Model attached to that chain.Request callbacks: defined in the run()/apply() methods used for issuing a request, e.g. chain.run(input, callbacks=[handler]), which will be used for that specific request only, and all sub-requests that it contains (e.g. a call to an LLMChain triggers a call to a Model, which uses the same handler passed in the call() method).The verbose argument is available on most objects throughout the API (Chains, Models, Tools, Agents, etc.) as a constructor argument, e.g. LLMChain(verbose=True), and it is equivalent to passing a ConsoleCallbackHandler to the callbacks argument of that object and all child objects. This is useful for debugging, as it will log all events to the console.When do you want to use each of these?‚ÄãConstructor callbacks are most useful for use