vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid

Home Page:https://sdk.vercel.ai/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`useChat` response message ID changes during streaming when `streamMode: "text"`

Yonom opened this issue · comments

Description

When useChat's streamMode is set to "text", the ID of the response message seems to change on each intermediate stream result.

Expectation: The message ID should be stable, since the result represents the same message. The behavior should be consistent between the two streamMode variants

The following is the output from the code example:
image

Code example

const TestButton = () => {
  const chat = useChat({ streamMode: "text" });
  const handleAdd = () => {
    chat.append({
        role: "user",
        content: "hii"
      });
  };

  console.log(chat.messages);
  
  return <button onClick={handleAdd}>Add test message</button>
}

Additional context

No response

Thanks!