Stop Streaming Early and Save Partial Response to History #5548
Replies: 2 comments 1 reply
-
|
Adding @eavanvalkenburg to comment |
Beta Was this translation helpful? Give feedback.
-
|
@CristinaStn thanks for posting, we could add a The other problem is that the finalizers are designed to be flexible, so in some cases it just combines update into a single response, but it can also be used to update UI, to store in file storage, etc. which is all circumvented when setting So, the best alternative, is to use a @westey-m has also done a lot of looking into different approaches here, he might have some other insights to share, but the long and short of it, is |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to stop agent streaming early (e.g., user clicks "Stop" button) and save the partial response to the history provider. The use case is:
The Problem I Encountered
When I break the stream loop and call get_final_response(), it consumes the entire remaining stream:
Workaround I Found
Setting the internal
ResponseStream._consumedflag before callingget_final_response():This works - both user and truncated assistant messages are saved to history correctly.
Concerns with my workaround:
Questions: is there:
Environment
Beta Was this translation helpful? Give feedback.
All reactions