Skip to content

Commit a7cf99b

Browse files
committed
Make text field optional in file annotation content schema
The file-parser plugin returns content arrays containing both text and image elements. Image elements (type: "image_url") do not have a text property, causing validation errors. This change makes the text field optional to support both element types whilst maintaining backwards compatibility with text-only content. Fixes validation error: "Invalid input: expected string, received undefined" Signed-off-by: Sora Morimoto <sora@morimoto.io>
1 parent c948aba commit a7cf99b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/chat/schemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const OpenRouterNonStreamChatCompletionResponseSchema = z.union([
113113
z
114114
.object({
115115
type: z.string(),
116-
text: z.string(),
116+
text: z.string().optional(),
117117
})
118118
.passthrough(),
119119
)
@@ -237,7 +237,7 @@ export const OpenRouterStreamChatCompletionChunkSchema = z.union([
237237
z
238238
.object({
239239
type: z.string(),
240-
text: z.string(),
240+
text: z.string().optional(),
241241
})
242242
.passthrough(),
243243
)

0 commit comments

Comments
 (0)