From d5bda2904dcb7279d4addff8bbc93cb206fdc7d6 Mon Sep 17 00:00:00 2001 From: DDMeaqua Date: Thu, 7 Nov 2024 19:45:27 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20o1=E6=A8=A1=E5=9E=8B=E4=BD=BF=E7=94=A8?= =?UTF-8?q?max=5Fcompletion=5Ftokens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/client/platforms/openai.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 6e893ed148f..7c1588440b2 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -65,6 +65,7 @@ export interface RequestPayload { frequency_penalty: number; top_p: number; max_tokens?: number; + max_completion_tokens?: number; } export interface DalleRequestPayload { @@ -233,6 +234,11 @@ 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. }; + // O1 使用 max_completion_tokens 控制token数 (https://platform.openai.com/docs/guides/reasoning#controlling-costs) + if (isO1) { + requestPayload["max_completion_tokens"] = modelConfig.max_tokens; + } + // add max_tokens to vision model if (visionModel) { requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000);