From 08fa22749aea8f497811f684bd9c7ef68d698666 Mon Sep 17 00:00:00 2001 From: fred-bf <157469842+fred-bf@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:28:01 +0800 Subject: [PATCH] fix: add max_tokens when using vision model (#4157) --- app/client/platforms/openai.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 919716bfb0a..437aff582ac 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -110,6 +110,16 @@ export class ChatGPTApi implements LLMApi { // Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore. }; + // add max_tokens to vision model + if (visionModel) { + Object.defineProperty(requestPayload, "max_tokens", { + enumerable: true, + configurable: true, + writable: true, + value: Math.max(modelConfig.max_tokens, 4096), + }); + } + console.log("[Request] openai payload: ", requestPayload); const shouldStream = !!options.config.stream;