(litellm sdk - perf improvement) - use O(1) set lookups for checking llm providers / models (#7672)

* fix get model info logic to use O(1) lookups

* perf - use O(1) lookup for get llm provider
This commit is contained in:
Ishaan Jaff 2025-01-10 14:16:30 -08:00 committed by GitHub
parent b3bd15e35a
commit c999b4efe1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 5 deletions

View file

@ -133,6 +133,7 @@ from litellm.types.utils import (
Function,
ImageResponse,
LlmProviders,
LlmProvidersSet,
Message,
ModelInfo,
ModelInfoBase,
@ -4108,9 +4109,7 @@ def _get_model_info_helper( # noqa: PLR0915
):
_model_info = None
if custom_llm_provider and custom_llm_provider in [
provider.value for provider in LlmProviders
]:
if custom_llm_provider and custom_llm_provider in LlmProvidersSet:
# Check if the provider string exists in LlmProviders enum
provider_config = ProviderConfigManager.get_provider_model_info(
model=model, provider=LlmProviders(custom_llm_provider)