From 3ddfde59cfbe30ab73d486f2c7113f451a478ba2 Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Fri, 2 Aug 2024 13:25:28 -0700 Subject: [PATCH] feat(ai-sdk/useChat): assistant message append support (#627) --- .changeset/stupid-rice-tell.md | 5 +++++ .../src/ui/use-chat/VercelUseChatThreadRuntime.tsx | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 .changeset/stupid-rice-tell.md diff --git a/.changeset/stupid-rice-tell.md b/.changeset/stupid-rice-tell.md new file mode 100644 index 000000000..d069baf7c --- /dev/null +++ b/.changeset/stupid-rice-tell.md @@ -0,0 +1,5 @@ +--- +"@assistant-ui/react-ai-sdk": patch +--- + +feat: assistant message append support diff --git a/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatThreadRuntime.tsx b/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatThreadRuntime.tsx index 1d9862384..faa922402 100644 --- a/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatThreadRuntime.tsx +++ b/packages/react-ai-sdk/src/ui/use-chat/VercelUseChatThreadRuntime.tsx @@ -63,11 +63,6 @@ export class VercelUseChatThreadRuntime implements ReactThreadRuntime { public async append(message: AppendMessage): Promise { // add user message - if (message.role !== "user") - throw new Error( - "Only appending user messages are supported in VercelUseChatRuntime. This is likely an internal bug in assistant-ui.", - ); - if (message.content.length !== 1 || message.content[0]?.type !== "text") throw new Error( "Only text content is supported by VercelUseChatRuntime. Use the Edge runtime for image support.", @@ -80,7 +75,7 @@ export class VercelUseChatThreadRuntime implements ReactThreadRuntime { this.vercel.setMessages(newMessages); await this.vercel.append({ - role: "user", + role: message.role, content: message.content[0].text, }); }