assistant-ui
assistant-ui copied to clipboard
Trigger response on initial messages
I want to start a thread with an initial user message received by the search params.
const searchParams = useSearchParams();
const message = searchParams.get("message");
const runtime = useChatRuntime({
api: "/api/chat",
initialMessages: [
{
role: "user",
content: [{ type: "text", text: message || "" }],
},
],
});
It adds the message correctly to the thread but I haven't found any programmatic way to force an assistant response, I need to add a new message manually.
Using append instead of initialMessages doesn't do the trick since it responds with an empty response (the api call is cancelled for some reason)