mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: remove temperature parameter for GPT-5 models
GPT-5 no longer supports the temperature parameter in its API. This commit removes the temperature field from GPT-5 requests to prevent API errors when using LiteLLM or other proxies. Fixes #6965
This commit is contained in:
parent
5e07bc42d0
commit
10eeecefff
3 changed files with 10 additions and 7 deletions
|
|
@ -634,7 +634,8 @@ describe("OpenAiNativeHandler", () => {
|
|||
expect(body1).toContain('"effort":"medium"')
|
||||
expect(body1).toContain('"summary":"auto"')
|
||||
expect(body1).toContain('"verbosity":"medium"')
|
||||
expect(body1).toContain('"temperature":1')
|
||||
// GPT-5 no longer supports temperature parameter
|
||||
expect(body1).not.toContain('"temperature"')
|
||||
expect(body1).toContain('"max_output_tokens"')
|
||||
|
||||
// Verify the streamed content
|
||||
|
|
@ -856,7 +857,8 @@ describe("OpenAiNativeHandler", () => {
|
|||
expect(body2).toContain('"effort":"low"')
|
||||
expect(body2).toContain('"summary":"auto"')
|
||||
expect(body2).toContain('"verbosity":"medium"')
|
||||
expect(body2).toContain('"temperature":1')
|
||||
// GPT-5 no longer supports temperature parameter
|
||||
expect(body2).not.toContain('"temperature"')
|
||||
expect(body2).toContain('"max_output_tokens"')
|
||||
|
||||
// Clean up
|
||||
|
|
@ -906,7 +908,8 @@ describe("OpenAiNativeHandler", () => {
|
|||
expect(body3).toContain('"effort":"minimal"')
|
||||
expect(body3).toContain('"summary":"auto"')
|
||||
expect(body3).toContain('"verbosity":"high"')
|
||||
expect(body3).toContain('"temperature":1')
|
||||
// GPT-5 no longer supports temperature parameter
|
||||
expect(body3).not.toContain('"temperature"')
|
||||
expect(body3).toContain('"max_output_tokens"')
|
||||
|
||||
// Clean up
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
|
|||
stream: boolean
|
||||
reasoning?: { effort: ReasoningEffortWithMinimal; summary?: "auto" }
|
||||
text?: { verbosity: VerbosityLevel }
|
||||
temperature?: number
|
||||
// temperature parameter removed - GPT-5 no longer supports it
|
||||
max_output_tokens?: number
|
||||
previous_response_id?: string
|
||||
}
|
||||
|
|
@ -289,7 +289,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
|
|||
},
|
||||
}),
|
||||
text: { verbosity: (verbosity || "medium") as VerbosityLevel },
|
||||
temperature: this.options.modelTemperature ?? GPT5_DEFAULT_TEMPERATURE,
|
||||
// GPT-5 no longer supports temperature parameter
|
||||
// Explicitly include the calculated max output tokens for GPT‑5.
|
||||
// Use the per-request reserved output computed by Roo (params.maxTokens from getModelParams).
|
||||
...(model.maxTokens ? { max_output_tokens: model.maxTokens } : {}),
|
||||
|
|
|
|||
|
|
@ -142,9 +142,9 @@ export function getModelParams({
|
|||
reasoning: getAnthropicReasoning({ model, reasoningBudget, reasoningEffort, settings }),
|
||||
}
|
||||
} else if (format === "openai") {
|
||||
// Special case for o1 and o3-mini, which don't support temperature.
|
||||
// Special case for o1, o3-mini, and GPT-5 models, which don't support temperature.
|
||||
// TODO: Add a `supportsTemperature` field to the model info.
|
||||
if (modelId.startsWith("o1") || modelId.startsWith("o3-mini")) {
|
||||
if (modelId.startsWith("o1") || modelId.startsWith("o3-mini") || modelId.startsWith("gpt-5")) {
|
||||
params.temperature = undefined
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue