From 2b7a973a333ec553b912220e8033cb88feb80c4b Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Mon, 27 May 2024 22:56:26 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=20fix:=20Azure=20Bug,=20short=20de?= =?UTF-8?q?fault=20`max=5Ftokens`=20response=20using=20`gpt-4-vision-previ?= =?UTF-8?q?ew`=20(#2885)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/clients/OpenAIClient.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/app/clients/OpenAIClient.js b/api/app/clients/OpenAIClient.js index dbb066534c..1635e600ca 100644 --- a/api/app/clients/OpenAIClient.js +++ b/api/app/clients/OpenAIClient.js @@ -1108,7 +1108,12 @@ ${convo} } if (this.azure || this.options.azure) { - // Azure does not accept `model` in the body, so we need to remove it. + /* Azure Bug, extremely short default `max_tokens` response */ + if (!modelOptions.max_tokens && modelOptions.model === 'gpt-4-vision-preview') { + modelOptions.max_tokens = 4000; + } + + /* Azure does not accept `model` in the body, so we need to remove it. */ delete modelOptions.model; opts.baseURL = this.langchainProxy