mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(openai/gpt-5): detect gpt-5.4+ in prefixed custom deployment names
is_model_gpt_5_4_plus_model required the model name to start with "gpt-5.", so prefixed Azure deployment names like my-prefix-gpt-5.5 returned False and the Responses API bridge never engaged, causing "Function tools with reasoning_effort are not supported" errors on chat completions. Locate "gpt-5." inside the last path segment and run the existing version parse from there, matching the substring approach already used by is_model_gpt_5_model. Fixes #28782.
This commit is contained in:
parent
e15b37a18e
commit
9b0da0618b
2 changed files with 29 additions and 2 deletions
|
|
@ -103,10 +103,16 @@ class OpenAIGPT5Config(OpenAIGPTConfig):
|
|||
|
||||
@classmethod
|
||||
def is_model_gpt_5_4_plus_model(cls, model: str) -> bool:
|
||||
"""Check if the model is gpt-5.4 or newer (5.4, 5.5, 5.6, etc., including pro)."""
|
||||
"""Check if the model is gpt-5.4 or newer (5.4, 5.5, 5.6, etc., including pro).
|
||||
|
||||
Handles custom deployment names with prefixes (e.g. Azure deployments
|
||||
like ``my-prefix-gpt-5.5``) by locating ``gpt-5.`` inside the name.
|
||||
"""
|
||||
model_name = model.split("/")[-1]
|
||||
if not model_name.startswith("gpt-5."):
|
||||
idx = model_name.find("gpt-5.")
|
||||
if idx == -1:
|
||||
return False
|
||||
model_name = model_name[idx:]
|
||||
try:
|
||||
version_str = model_name.replace("gpt-5.", "").split("-")[0]
|
||||
major = version_str.split(".")[0]
|
||||
|
|
|
|||
|
|
@ -342,6 +342,27 @@ def test_gpt5_4_pro_allows_reasoning_effort_xhigh(config: OpenAIConfig):
|
|||
assert params["reasoning_effort"] == "xhigh"
|
||||
|
||||
|
||||
def test_is_model_gpt_5_4_plus_model_prefixed_deployment_names(
|
||||
gpt5_config: OpenAIGPT5Config,
|
||||
):
|
||||
"""Custom deployment names with prefixes (e.g. Azure) are recognized as gpt-5.4+."""
|
||||
assert gpt5_config.is_model_gpt_5_4_plus_model("my-prefix-gpt-5.5")
|
||||
assert gpt5_config.is_model_gpt_5_4_plus_model("azure/something-something-gpt-5.5")
|
||||
assert gpt5_config.is_model_gpt_5_4_plus_model("my-prefix-gpt-5.4-pro")
|
||||
assert gpt5_config.is_model_gpt_5_4_plus_model("gpt-5.4")
|
||||
assert gpt5_config.is_model_gpt_5_4_plus_model("openai/gpt-5.6")
|
||||
|
||||
|
||||
def test_is_model_gpt_5_4_plus_model_rejects_non_5_4_plus_names(
|
||||
gpt5_config: OpenAIGPT5Config,
|
||||
):
|
||||
"""Names below 5.4 or merely containing gpt-5 without a version must not match."""
|
||||
assert not gpt5_config.is_model_gpt_5_4_plus_model("my-prefix-gpt-5.2")
|
||||
assert not gpt5_config.is_model_gpt_5_4_plus_model("my-gpt-5-deployment")
|
||||
assert not gpt5_config.is_model_gpt_5_4_plus_model("gpt-5")
|
||||
assert not gpt5_config.is_model_gpt_5_4_plus_model("azure/prefix-gpt-5.x")
|
||||
|
||||
|
||||
def test_gpt5_4_mini_allows_reasoning_effort_xhigh(config: OpenAIConfig):
|
||||
"""gpt-5.4-mini supports reasoning_effort='xhigh'."""
|
||||
params = config.map_openai_params(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue