chainlit
chainlit copied to clipboard
cl.LangchainCallbackHandler() - Not working with Langchain v1
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:
- Create a Langchain agent with langchain v1.0.1
- 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()
- Start
- 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.