chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

cl.LangchainCallbackHandler() - Not working with Langchain v1

Open pra1had opened this issue 3 weeks ago • 5 comments
trafficstars

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.

pra1had avatar Oct 26 '25 02:10 pra1had