Skip to content

Commit

Permalink
fix: make AppendMessage attachments field optional for now (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Sep 9, 2024
1 parent 658dfa1 commit 7ed296b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-cars-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@assistant-ui/react": patch
---

fix: make AppendMessage attachments field optional for now
2 changes: 1 addition & 1 deletion packages/react-ai-sdk/src/ui/utils/toCreateMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/types/AssistantTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 7ed296b

Please sign in to comment.