How to pass all conversation message for every request with useChat? #2854
Unanswered
marclelamy
asked this question in
Help
Replies: 1 comment 2 replies
-
The best would be to call use chat in a function and pass the initial message every time but we can't call a hook from a function... |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm building a chatbot app using Vercel AI SDK where users can generate multiple answers for every question, creating a tree-like conversation structure (see image below). For context preservation across branches, I need to pass the entire message array to the AI on each request.
The current challenge is that the useChat hook doesn't allow passing or updating the full message array, even with setMessages as I would need to run append() right before.
Is there a way to achieve this tree-structured conversation with full context passing while maintaining tools/agent support in Vercel AI SDK? Or are there any recommended workarounds?
Beta Was this translation helpful? Give feedback.
All reactions