Skip to content

cl.LangchainCallbackHandler() - Not working with Langchain v1 #2607

@pra1had

Description

@pra1had

Describe the bug
I have a very simple agent (Langchain's Demo use case agent) which I need to integrate with chainlit including showing the COT. I believe this is broken due to package changes done by Langchain in their v1.x.x release.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Langchain agent with langchain v1.0.1
  2. Create a chainlit app with LangchainCallbackHandler
@cl.on_message
async def on_message(message: cl.Message):
    res = await supervisor_agent.astream(message.content, callbacks=[cl.LangchainCallbackHandler()])
    # res = await cl.make_async(supervisor_agent)(message.content, callbacks=[cl.LangchainCallbackHandler()])
    await cl.Message(content=res["answer"]).send()
  1. Start
  2. Getting the following error
  File "[REDACTED]/venv/lib/python3.13/site-packages/chainlit/langchain/callbacks.py", line 6, in <module>
    from langchain.callbacks.tracers.schemas import Run
ModuleNotFoundError: No module named 'langchain.callbacks'

Expected behavior
Should show the chain of thought and tool calls.

Screenshots
If applicable, add screenshots to help explain your problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendPertains to the Python backend.bugSomething isn't workingneeds-triage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions