feat (ui/react): support resuming an ongoing stream#6000
Closed
jeremyphilemon wants to merge 16 commits intomainfrom
Closed
feat (ui/react): support resuming an ongoing stream#6000jeremyphilemon wants to merge 16 commits intomainfrom
jeremyphilemon wants to merge 16 commits intomainfrom
Conversation
16bbbbf to
7dad719
Compare
5e9426f to
89b2f75
Compare
lgrammel
reviewed
Apr 26, 2025
|
|
||
| To resume a chat stream, you can use the `experimental_resume` function returned by the `useChat` hook. You will typically call this function during the initial mount of the hook. | ||
|
|
||
| ``` |
Contributor
Author
There was a problem hiding this comment.
updated, but can you verify since it was unclear what to improve
lgrammel
reviewed
Apr 26, 2025
lgrammel
reviewed
Apr 26, 2025
lgrammel
reviewed
Apr 26, 2025
lgrammel
reviewed
Apr 26, 2025
lgrammel
reviewed
Apr 26, 2025
Collaborator
|
CC @iteratetograceness for visibility regarding the useChat chat store refactoring. |
lgrammel
reviewed
Apr 29, 2025
lgrammel
reviewed
Apr 29, 2025
lgrammel
reviewed
Apr 29, 2025
lgrammel
reviewed
Apr 29, 2025
lgrammel
reviewed
Apr 29, 2025
lgrammel
reviewed
Apr 29, 2025
lgrammel
reviewed
Apr 29, 2025
ed93a48 to
99f9f6f
Compare
Contributor
Author
|
Created a new pull request since the tests here have bugged out #6052 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
This pull request adds the ability for clients to resume an ongoing chat generation stream after a network disconnect.
Summary
This pull request adds support for the
useChathook to resume an ongoing chat generation stream by exposingexperimental_resume()that can be called by any client, typically during the initial mount of the hook.The
experimental_resumefunction makes aGETrequest to the api endpoint you've initialized the hook with (or/api/chatby default) and streams the contents of the stream if it is active or fails silently if it has ended.In order for
experimental_resumeto work as intended, it requires the usage of theresumable-streampackage for stream creation and a redis instance for the package to manage the pub/sub mechanism.Verification
An example has been added at
examples/next-openai/app/use-chat-resumeto test the feature. Follow the following steps to test it end-to-end:http://localhost:3000/use-chat-resumeTasks
pnpm prettier-fixin the project root)Future Work
Possibly unify
resumeChatApiandcallChatApiand avoid code duplication.