fix(openai): omit temperature for models that don't support it (#215)#233
Conversation
…ode-Org#215) claude-opus-4-7 (and similar) reject requests through the OpenAI-Compatible provider with a 400 error because 'temperature' is deprecated/unsupported. Honor the model's existing supportsTemperature flag (already respected by openai-native, gemini, lite-llm and vercel-ai-gateway) and omit temperature from the streaming request when it is explicitly set to false. undefined keeps sending temperature, preserving current behavior for all other models. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR makes ChangesConditional Temperature Parameter Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/api/providers/__tests__/openai.spec.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ure gate (Zoo-Code-Org#215) Add two tests so the temperature expression's branches are fully exercised: - explicit modelTemperature (left side of the `??`) - deepseek-reasoner default of DEEP_SEEK_DEFAULT_TEMPERATURE (truthy ternary) Closes the partial-branch gap codecov/patch flagged on line 162. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Fixes #215. Using
claude-opus-4-7through the OpenAI-Compatible provider fails with a400error because the upstream API (e.g. via LiteLLM/Bedrock) rejectstemperatureas deprecated/unsupported for that model.OpenAiHandler.createMessage()always includedtemperaturein the streaming request. This honors the model's existingsupportsTemperatureflag — already respected byopenai-native,gemini,lite-llmandvercel-ai-gateway— and omitstemperaturewhen it is explicitly set tofalse.Behavior
supportsTemperature: false→temperatureis omitted from the request.undefined/true→temperatureis sent exactly as before (no behavior change for existing models).Users hitting this can set Supports temperature → off on the OpenAI-Compatible model (the flag already exists in
ModelInfoand the settings UI).Testing
Added tests asserting
temperatureis omitted whensupportsTemperature: falseand included by default.Summary by CodeRabbit