Skip to content

Commit 0511808

Browse files
committed
use max_completion_tokens
1 parent 42eff64 commit 0511808

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/client/platforms/openai.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,13 @@ export class ChatGPTApi implements LLMApi {
239239
// Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore.
240240
};
241241

242-
if (isO1OrO3) {
242+
if (isGpt5) {
243+
// Remove max_tokens if present
244+
delete requestPayload.max_tokens;
245+
// Add max_completion_tokens (or max_completion_tokens if that's what you meant)
246+
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
247+
248+
} else if (isO1OrO3) {
243249
// by default the o1/o3 models will not attempt to produce output that includes markdown formatting
244250
// manually add "Formatting re-enabled" developer message to encourage markdown inclusion in model responses
245251
// (https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/reasoning?tabs=python-secure#markdown-output)
@@ -252,12 +258,9 @@ export class ChatGPTApi implements LLMApi {
252258
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
253259
}
254260

255-
if (isGpt5) {
256-
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
257-
}
258261

259262
// add max_tokens to vision model
260-
if (visionModel && !isO1OrO3) {
263+
if (visionModel && !isO1OrO3 && ! isGpt5) {
261264
requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000);
262265
}
263266
}

0 commit comments

Comments
 (0)