From c9791acd85638e5b9f72033b3872c8c46d70fb80 Mon Sep 17 00:00:00 2001 From: nai-degen Date: Sat, 27 Jan 2024 13:24:11 -0600 Subject: [PATCH] makes gpt4-v input validation less strict to accomodate Risu --- .../request/preprocessors/transform-outbound-payload.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/proxy/middleware/request/preprocessors/transform-outbound-payload.ts b/src/proxy/middleware/request/preprocessors/transform-outbound-payload.ts index 1abe89b..93ba5d7 100644 --- a/src/proxy/middleware/request/preprocessors/transform-outbound-payload.ts +++ b/src/proxy/middleware/request/preprocessors/transform-outbound-payload.ts @@ -38,7 +38,7 @@ const OpenAIV1ChatContentArraySchema = z.array( z.union([ z.object({ type: z.literal("text"), text: z.string() }), z.object({ - type: z.literal("image_url"), + type: z.union([z.literal("image"), z.literal("image_url")]), image_url: z.object({ url: z.string().url(), detail: z.enum(["low", "auto", "high"]).optional().default("auto"), @@ -52,9 +52,12 @@ export const OpenAIV1ChatCompletionSchema = z model: z.string().max(100), messages: z.array( z.object({ - role: z.enum(["system", "user", "assistant"]), + role: z.enum(["system", "user", "assistant", "tool", "function"]), content: z.union([z.string(), OpenAIV1ChatContentArraySchema]), name: z.string().optional(), + tool_calls: z.array(z.any()).optional(), + function_call: z.array(z.any()).optional(), + tool_call_id: z.string().optional(), }), { required_error: