Final Answer streaming
If streaming is enabled at the LLM level, Langchain will only stream the intermediate steps. You can enable final answer streaming by passingstream_final_answer=True to the callback handler.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
llm = OpenAI(temperature=0)
llm_math = LLMMathChain.from_llm(llm=llm)
@cl.on_message
async def main(message: cl.Message):
res = await llm_math.acall(message.content, callbacks=[cl.LangchainCallbackHandler()])
await cl.Message(content="Hello").send()
stream_final_answer=True to the callback handler.
# Optionally, you can also pass the prefix tokens that will be used to identify the final answer
answer_prefix_tokens=["FINAL", "ANSWER"]
cl.LangchainCallbackHandler(
stream_final_answer=True,
answer_prefix_tokens=answer_prefix_tokens,
)
AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTIONWas this page helpful?