Problem using "useVercelUseAssistantRuntime" and "useAssistant"
Using useVercelUseAssistantRuntime seems to be broken with streaming messages. When I send a message I can see the response is streamed in the network tab, but in the frontend it's not updated. Also the message I submit is not displayed in the chat.
When I reload the page I can see the response and my own message.
I managed to get it to work using local runtime and custom streaming functions, but I would really like to stick to the provided utils if possible.
"use client";
import { useAssistant } from "@ai-sdk/react";
import { AssistantRuntimeProvider } from "@assistant-ui/react";
import { useVercelUseAssistantRuntime } from "@assistant-ui/react-ai-sdk";
import { Thread } from "@/components/assistant-ui/thread";
import { ThreadList } from "@/components/assistant-ui/thread-list";
export const Assistant = () => {
const assistant = useAssistant({
api: "/api/assistant",
});
const runtime = useVercelUseAssistantRuntime(assistant, {
});
return (
<AssistantRuntimeProvider runtime={runtime}>
<div className="grid h-dvh grid-cols-[200px_1fr] gap-x-2 px-4 py-4">
<ThreadList />
<Thread />
</div>
</AssistantRuntimeProvider>
);
};
backend: https://github.com/karladler/assistant-ui-test/blob/main/app/api/assistant/route.ts
reproduced here: https://github.com/karladler/assistant-ui-test
Edit: The Problem seems to be introduced in Version 10, rolling back to v9 solves the problem.
+1 -- currently, the assistant-ui example for using an assistant with openAI, which relies on Vercel AI SDK and useVercelUseAssistantRuntime does not work in my hands either. i.e. the with-openai-assistants example is broken.
- The backend streams responses, the frontend web dev console shows they arrived, the UI does not show them.
- Clicking the 'Reload' button throws error
Error: Runtime does not support reloading messages.
Repro
Create new assistant at openai.com Try assistant in the playground, copy the assistant ID Create new API key for the assistant, copy it
git clone [email protected]:assistant-ui/assistant-ui.git
cd assistant-ui/
pnpm install
cd examples/with-openai-assistants
cat > .env.local # put the openai info here
ASSISTANT_ID=asst_o1V.....
OPENAI_API_KEY=sk-proj-.....
pnpm build
pnpm run dev
Open http://localhost:3000/ # or whatever port was shown in the console when running pnpm run dev
Try to use assistant-ui as below
project does build, loads initial page
Click what-is-assistant-ui? shows response returned from openAI assistant, but UI does not display any streaming and does not display final response:
Click Refresh, get error
FWIW: Seems the Vercel code has other issues? the live RSC demo linked from Assistant-ui.com throws on clicking the top-level example button:
REPRO
Load url, click button, get error https://assistant-ui-rsc-example.vercel.app/
Load
Click
Get error
@karladler @bobbyo Let me know if you're still getting this issue, #2041 fixed it for me
closing as stale, this should be fixed now