-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: Document how to pass callbacks with Runnable methods (e.g., .invoke / .batch) #16379
Comments
🤖 In the LangChain framework, callbacks are passed through the Here is an example of how you can pass a callback using the from langchain_core.tracers.root_listeners import RootListenersTracer
# Define your callbacks
def on_start(run):
print(f"Start: {run}")
def on_end(run):
print(f"End: {run}")
def on_error(run):
print(f"Error: {run}")
# Create a RunnableConfig with your callbacks
config = {
"callbacks": [
RootListenersTracer(
config=config,
on_start=on_start,
on_end=on_end,
on_error=on_error,
)
],
}
# Pass the config to the invoke method
output = runnable.invoke(input, config) In this example, The same approach can be used for the The
The
I hope this helps! If you have any other questions, feel free to ask. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
The callbacks get started demo code was updated , replacing the chain.run() command ( which is now depricated) ,with the updated chain.invoke() command. Solving the following issue : #16379 Twitter/X : @Hazxhx
…ngchain-ai#18403) ## PR title Docs: Updated callbacks/index.mdx adding example on runnable methods ## PR message - **Description:** Updated callbacks/index.mdx adding an example on how to pass callbacks to the runnable methods (invoke, batch, ...) - **Issue:** langchain-ai#16379 - **Dependencies:** None
The callbacks get started demo code was updated , replacing the chain.run() command ( which is now depricated) ,with the updated chain.invoke() command. Solving the following issue : langchain-ai#16379 Twitter/X : @Hazxhx
Issue with current documentation:
https://python.langchain.com/docs/modules/callbacks/#when-do-you-want-to-use-each-of-these
Idea or request for content:
Document how to pass callbacks via .invoke
The text was updated successfully, but these errors were encountered: