Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to pass Callback Handlers #1285

Open
ramnathv opened this issue Feb 26, 2024 · 1 comment
Open

Add support to pass Callback Handlers #1285

ramnathv opened this issue Feb 26, 2024 · 1 comment

Comments

@ramnathv
Copy link

馃殌 The feature

Langchain supports callbacks to be passed to the function invoking the LLM. Support passing these to Langchain.

Motivation, pitch

This allows tools like Chainlit to display step by step outputs.

@cl.on_message
async def on_message(message: cl.Message):
    runnable = cl.user_session.get("runnable")  # type: Runnable

    msg = cl.Message(content="")

    async for chunk in runnable.astream(
        {"question": message.content},
        config=RunnableConfig(callbacks=[cl.LangchainCallbackHandler()]),
    ):
        await msg.stream_token(chunk)

    await msg.send()
@deshraj
Copy link
Collaborator

deshraj commented Feb 27, 2024

Thank you for opening this issue, @ramnathv! We're looking into it. 馃専

If you're interested, we'd welcome your contribution on this. Feel free to ask for any guidance you need.

Happy coding! 馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants