Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the request fails, the previous message is not restored #2085

Closed
AntzyMo opened this issue Jun 25, 2024 · 3 comments
Closed

If the request fails, the previous message is not restored #2085

AntzyMo opened this issue Jun 25, 2024 · 3 comments
Assignees
Labels
ai/ui bug Something isn't working

Comments

@AntzyMo
Copy link
Contributor

AntzyMo commented Jun 25, 2024

Description

If steamText encounters an error, messages of useChat will lose the messages sent by user due to error reporting. For example:

const messages = [
    {
        "role": "user",
        "content": "hi"
    },
    {
        "role": "assistant",
        "content": "hello"
    },
    {
        "role": "user",
        "content": "who are you?"
    }
]

If you send the last item of the messages array and an error is reported, the message who are you will be displayed. I think this is wrong and it looks like a bug.

So my idea is to restore to the previous message when an error is reported, including user

Code example

const previousMessages = messagesData.value;

Taking vue as an example, previousMessages should be changed to const previousMessages = messagesSnapshot, which can ensure the latest message records

Additional context

No response

@lgrammel
Copy link
Collaborator

Note: this came up internally as well.

@lgrammel lgrammel self-assigned this Jul 12, 2024
@jh3y
Copy link

jh3y commented Jul 12, 2024

Yep - This one gives the developer a little more work to do with the out of the box behavior.

Consider:

  1. Start a new chat
  2. Enter question
  3. System errors
  4. Wipes UI including users' question

The current workarounds rely on the developer maintaining a second shadow state of the AI state in order to provide better UX to their users.

In most cases, although the error message is most likely generic and related to the server itself, the user probably expects an error message in place of the streaming message coming in or appended to it with the option to reload or trigger a new message.

@lgrammel
Copy link
Collaborator

#2262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/ui bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants