ai
ai copied to clipboard
Add helper to useChat to completely reset the hook states
Feature Description
The issue mentioned under https://github.com/vercel/ai/issues/819 is not unique to isLoading. Other parameters like data
(containing payloads from the server) remain cached per id
even if the id changes. Which, without the stream resuming, is useless. If those states aren't designed to reset for some reason, there should be a resetHook
helper to set all values to their default values.
Use Case
An external useEffect
that can listen to the externally provided id
and reset the useChat()
to default as needed.
Additional context
No response
I'm exploring https://github.com/vercel/ai/pull/828 for this. You can just change key
to reset (see test case)