Skip to content

Conversation

@Abhinavexists
Copy link
Contributor

@Abhinavexists Abhinavexists commented Nov 18, 2025

Fixed a bug where GPT-5 temperature validation was case-sensitive, causing issues when users
specified Azure deployment names or model names in uppercase (e.g., "GPT-5-2025-01-01", "GPT-5-NANO"). The validation now correctly handles model names regardless of case.

Changes made:

  • Updated validate_temperature() method in BaseChatOpenAI to perform case-insensitive
    model name comparisons
  • Updated _get_encoding_model() method to use case-insensitive checks for tiktoken encoder
    selection
  • Added comprehensive unit tests to verify case-insensitive behavior with various case
    combinations

Issue: Fixes #34003

Dependencies: None

Test Coverage:

  • All existing tests pass
  • New test test_gpt_5_temperature_case_insensitive covers uppercase, lowercase, and
    mixed-case model names
  • Tests verify both non-chat GPT-5 models (temperature removed) and chat models (temperature
    preserved)
  • Lint and format checks pass (make lint, make format)

@github-actions github-actions bot added integration Related to a provider partner package integration openai fix and removed fix labels Nov 18, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 18, 2025

CodSpeed Performance Report

Merging #34012 will not alter performance

Comparing Abhinavexists:openai-case-sensitive (1081fe8) with master (cbaea35)1

Summary

✅ 6 untouched
⏩ 28 skipped2

Footnotes

  1. No successful run was found on master (4e4e5d7) during the generation of this report, so cbaea35 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 28 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@mdrxy mdrxy requested a review from Copilot November 24, 2025 00:57
Copilot finished reviewing on behalf of mdrxy November 24, 2025 01:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a case-sensitivity bug in GPT-5 model temperature validation that prevented users from using uppercase or mixed-case model names (common with Azure deployments). The fix ensures model name comparisons are case-insensitive for both temperature validation and tiktoken encoder selection.

Key changes:

  • Model name comparisons now use .lower() before checking with startswith() for GPT-5 and o1 models
  • Encoder selection logic refactored to use tuple-based startswith() (more Pythonic)
  • Comprehensive test coverage added for various case combinations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
libs/partners/openai/langchain_openai/chat_models/base.py Updated validate_temperature() and _get_encoding_model() methods to perform case-insensitive model name comparisons
libs/partners/openai/tests/unit_tests/chat_models/test_base.py Added parametrized test covering uppercase, mixed-case, and lowercase GPT-5 model names for both chat and non-chat variants

@mdrxy mdrxy merged commit 2ba3ce8 into langchain-ai:master Nov 24, 2025
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix integration Related to a provider partner package integration openai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BaseChatOpenAI handles temperature removal only for lower case names of reasoning models

2 participants