Merge pull request #21690 from BerriAI/litellm_perf_o_series_short_circuit

perf: optimize is_model_o_series_model with startswith
This commit is contained in:
ryan-crabbe 2026-02-24 14:59:53 -08:00 • committed by GitHub
commit 56a507073b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -131,9 +131,7 @@ 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 in litellm.open_ai_chat_completion_models and any(
model.startswith(pfx) for pfx in ("o1", "o3", "o4")
)
return model.startswith(("o1", "o3", "o4")) and model in litellm.open_ai_chat_completion_models
@overload
def _transform_messages(
@ -173,4 +171,4 @@ class OpenAIOSeriesConfig(OpenAIGPTConfig):
else:
return super()._transform_messages(
messages, model, is_async=cast(Literal[False], False)
)
)