chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

ConversationalRetrievalChain returning question first while streaming

Open sanket-rudder opened this issue 1 year ago • 0 comments

I have created simple chatbot using ConversationalRetrievalChain. I am trying to stream the answer using code below.

@cl.on_message async def main(message: cl.Message): chain = cl.user_session.get("chain") # type: ConversationalRetrievalChain cb = cl.LangchainCallbackHandler( stream_final_answer=True, force_stream_final_answer=True ) cb.answer_reached = True res = await chain.acall(message.content, callbacks=[cb])

Streaming is working as expected but I am getting question first in my output and then answer.

image

I tried to use different strings in answer_prefix_tokens as well but nothing changed.

sanket-rudder avatar Apr 09 '24 17:04 sanket-rudder