Intermidiate
Intermidiate
Suppose we want to stream not only the final outputs of the chain, but also some
intermediate steps. As an example let's take our Conversational RAG chain. Here we
reformulate the user question before passing it to the retriever. This reformulated
question is not returned as part of the final output. We could modify our chain to
return the new question, but for demonstration purposes we'll leave it as is.
AI: Task decomposition involves breaking up a complex task into smaller and simpler
steps.
We then ask a follow up question: "What are some common ways of doing it?" Leading
into the retrieval step, our history_aware_retriever will rephrase this question
using the conversation's context to ensure that the retrieval is meaningful.
Below we show a typical .astream_events loop, where we pass in the chain input and
emit desired results. See the API reference and streaming guide for more detail.
chat_history = [
("human", first_question),
("ai", first_answer),
]
Here we recover, token-by-token, the query that is passed into the retriever given
our question "What are some common ways of doing it?"