diff --git a/.changeset/four-cars-deliver.md b/.changeset/four-cars-deliver.md new file mode 100644 index 000000000..bdef212d2 --- /dev/null +++ b/.changeset/four-cars-deliver.md @@ -0,0 +1,5 @@ +--- +"@assistant-ui/react": patch +--- + +fix: make AppendMessage attachments field optional for now diff --git a/packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts b/packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts index e9be5efbc..1f5714657 100644 --- a/packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts +++ b/packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts @@ -19,7 +19,7 @@ export const toCreateMessage = async ( experimental_attachments: [ ...images, ...(await Promise.all( - message.attachments.map(async (m) => { + (message.attachments ?? []).map(async (m) => { if (m.file == null) throw new Error("Attachment did not contain a file"); return { diff --git a/packages/react/src/types/AssistantTypes.ts b/packages/react/src/types/AssistantTypes.ts index 3167181f0..7b51adc93 100644 --- a/packages/react/src/types/AssistantTypes.ts +++ b/packages/react/src/types/AssistantTypes.ts @@ -133,7 +133,8 @@ export type ThreadAssistantMessage = MessageCommonProps & { export type AppendMessage = CoreMessage & { parentId: string | null; - attachments: readonly MessageAttachment[]; + // TODO make required in the next major version + attachments?: readonly MessageAttachment[]; }; export type ThreadMessage =