OLS-3548 Omit temperature for models that deprecate it#3000
Conversation
Add temperature_supported flag to ModelParameters (default True). When False, the base LLMProvider strips temperature from params before passing them to the LLM client, preventing HTTP 400 errors from models like claude-sonnet-5 that reject the parameter. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a model-level ChangesTemperature Support Handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ols/src/llms/providers/provider.py (1)
382-392: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSimplify
_model_supports_temperatureby removing the deadgetattr/Nonebranch.
ModelConfig.parametersis declared asparameters: ModelParameters = ModelParameters(), so it always carries a value — thegetattrfallback and theif params is Noneguard can never trigger. Direct access is cleaner and preserves full type information for mypy strict mode.♻️ Proposed refactor
def _model_supports_temperature(self) -> bool: """Check whether the current model supports the temperature parameter.""" if self.provider_config is None: return True model_config = self.provider_config.models.get(self.model) if model_config is None: return True - params = getattr(model_config, "parameters", None) - if params is None: - return True - return params.temperature_supported + return model_config.parameters.temperature_supported🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ols/src/llms/providers/provider.py` around lines 382 - 392, Update _model_supports_temperature to access model_config.parameters directly and return its temperature_supported value, removing the getattr fallback and params None guard while preserving the existing provider_config and model_config None handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ols/src/llms/providers/provider.py`:
- Around line 382-392: Update _model_supports_temperature to access
model_config.parameters directly and return its temperature_supported value,
removing the getattr fallback and params None guard while preserving the
existing provider_config and model_config None handling.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 30b796f3-9d81-46ad-a570-ee0316ca07bf
📒 Files selected for processing (4)
examples/olsconfig.yamlols/app/models/config.pyols/src/llms/providers/provider.pytests/unit/llms/providers/test_bedrock.py
ModelConfig.parameters always has a default ModelParameters(), so the getattr fallback and None check can never trigger. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Addressed the CodeRabbit nitpick — removed the dead All 22 bedrock provider tests pass. |
|
@thoraxe: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
temperature_supportedboolean flag toModelParameters(defaults toTruefor backward compatibility)LLMProviderstripstemperaturefrom LLM params when the model's config setstemperature_supported: falseclaude-sonnet-5that have deprecated thetemperatureparameterHow to use
In
olsconfig.yaml, settemperature_supported: falseon any model that rejectstemperature:Models without this setting (or with
temperature_supported: true) continue to receivetemperatureas before.Test plan
temperature_supported=Falsetemperature_supported=True(default)Summary by CodeRabbit
New Features
temperatureparameter.temperature, the app now omits it automatically from outgoing requests.Documentation
Tests
temperatureis stripped or retained correctly, including when callers supply atemperaturevalue.