fix(o-series): generalize is_model_o_series_model to match any o+digit prefix

Replace the hardcoded startswith(("o1", "o3", "o4")) check with a broader
o+digit pattern, ensuring future o-series models (e.g. o2, o5) are
automatically recognized once added to open_ai_chat_completion_models.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Sameer Kankute 2026-03-05 15:54:53 +05:30
parent cdf2d67fc8
commit dd0ccdd8b2

View File

@ -131,7 +131,10 @@ class OpenAIOSeriesConfig(OpenAIGPTConfig):
def is_model_o_series_model(self, model: str) -> bool:
model = model.split("/")[-1] # could be "openai/o3" or "o3"
return model.startswith(("o1", "o3", "o4")) and model in litellm.open_ai_chat_completion_models
return (
len(model) > 1 and model[0] == "o" and model[1].isdigit()
and model in litellm.open_ai_chat_completion_models
)
@overload
def _transform_messages(