ai icon indicating copy to clipboard operation
ai copied to clipboard

Proposing `onAppend` callback method for `useChat` hook

Open qunash opened this issue 11 months ago • 0 comments

Feature Description

I propose adding an onAppend callback function to the useChatOptions. This callback would be invoked whenever a user message is appended to the chat list using the append function, triggering the API call to fetch the assistant's response.

type UseChatOptions = {
  // ...
  onAppend?: (message: Message | CreateMessage) => void;
  // ...
};

Use Case

The onAppend callback would be useful for enhancing the interactivity and responsiveness of the chat UI. By implementing the onAppend callback, developers can provide visual feedback or trigger animations when a user message is appended to the chat list, indicating that the assistant is processing the message and generating a response (e.g. "typing" indicator or animation).

Additional context

The onAppend callback would be invoked immediately after a user message is appended to the chat list using the append function, but before the API call is made to fetch the assistant's response.

qunash avatar Mar 15 '24 09:03 qunash