Great question — answering as the UphillTech team:
Have you seen this: https://python.langchain.com/docs/use_cases/question_answering/streaming/ First off, the chain is built so that it also return the retrieved documents - so if you call invoke , the contexts is also included in the results. Next, when you are streaming instead, if would stream the same values. You can see in the output example the results contains the context. On the client side you will have to know to handle the data you receive appropriately (assuming you want to do something different with each part) - there an example code in python just below the output that does this aggregation into separate parts that you can then use. I hope I understood the question and this...
Full answer by Tomer Cagan: https://stackoverflow.stackexchange.com/a/78335207 (CC BY-SA 4.0).
Need it done for your business? UphillTech.