Repository navigation
FIX Reject NaN in validate_temperature and validate_top_p - #3606
Open
Shivam Sharma (ShivamSharma43) wants to merge 4 commits into
Open
Shivam Sharma (ShivamSharma43) wants to merge 4 commits into
Shivam Sharma (ShivamSharma43) wants to merge 4 commits into
Conversation
Both checks were written as `value < low or value > high`, which is False for NaN, so a NaN temperature or top_p passed validation and only failed later when httpx refused to encode the request body. Use `not low <= value <= high` like the presence and frequency penalty validators. Fixes microsoft#3605 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Richard Lundeen (richlundeen)
approved these changes
Oct 28, 2026
Richard Lundeen (richlundeen)
left a comment
Contributor
There was a problem hiding this comment.
The chained bounds checks reject NaN and infinity while preserving None and the inclusive limits. The focused regression cases cover both validators.
No blocking issues found by code inspection. Tests were not run for this review. AI-assisted review (GitHub Copilot).
Contributor
Author
|
The only failing job here is |
…into fix/reject-nan-temperature-top-p
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #3605.
validate_temperatureandvalidate_top_pcheckedvalue < low or value > high. Every comparison with NaN isFalse, so a NaNtemperatureortop_ppassed validation.OpenAIChatTarget,OpenAIResponseTarget,OpenAICompletionTarget,LiteLLMChatTargetandAzureMLChatTargetthen stored it in their identifier, and every send failed when httpx encoded the request body (Out of range float values are not JSON compliant).Changes:
not 0 <= value <= high, the same form asvalidate_presence_penaltyandvalidate_frequency_penalty. NaN is rejected with the existing range message.infand-infwere already rejected, and finite values behave as before.Tests and Documentation
tests/unit/prompt_target/test_target_utils.py:nan,infand-infcases for both validators, matching the existing penalty tests. The twonancases fail onmain; theinfcases already passed and document the current behavior.pytest tests/unit/prompt_target -k "temperature or top_p or validat or init": 319 passed, 15 skipped.ruff check,ruff formatandty checkpass on the changed files.🤖 Generated with Claude Code