Closed wangpengfei2048 closed 3 weeks ago
This is a Langchain question but I am not sure you can get the source documents with the astream
method
Yes , It is a Langchain question, they are two different methods to ask. chainlit also changes it using LCEL. and I change it , but I want to use source_documents as before, can you give some suggestion?? there is an example with chainlit ,but the old method..
Having the same question as @wangpengfei2048
This post on discord covers that I believe.
what is the link, i cant reach it.
now I use astream_log() to get the answer and the source_documents
Glad you found a way to solve your issue ! I'm marking is as resolved 😉
code : @cl.on_message async def main(message: cl.Message): chain = cl.user_session.get("chain") # type: ConversationalRetrievalChain cb = cl.AsyncLangchainCallbackHandler()
code: async for chunk in runnable.astream( message.content, config=RunnableConfig(callbacks=[cl.LangchainCallbackHandler()]), ): await res.stream_token(chunk)