mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
fix(openai_like): check JSON provider endpoints through one helper
Moves the supported_endpoints lookup into JSONProviderRegistry.supports_endpoint so the embeddings check and the Responses check share it. This keeps the type discipline and basedpyright counts at their merge-base values
This commit is contained in:
parent
154577ee01
commit
142fc38d69
2 changed files with 7 additions and 13 deletions
|
|
@ -12,7 +12,6 @@ from litellm._logging import verbose_logger
|
|||
from litellm.types.utils import ProviderSpecificModelInfo
|
||||
|
||||
_PROVIDER_INFO_ADAPTER: Final = TypeAdapter(ProviderSpecificModelInfo)
|
||||
_SUPPORTED_ENDPOINTS_ADAPTER: Final = TypeAdapter(list[str])
|
||||
|
||||
|
||||
class SimpleProviderConfig:
|
||||
|
|
@ -27,9 +26,7 @@ class SimpleProviderConfig:
|
|||
self.param_mappings = data.get("param_mappings", {})
|
||||
self.constraints = data.get("constraints", {})
|
||||
self.special_handling = data.get("special_handling", {})
|
||||
self.supported_endpoints: list[str] = _SUPPORTED_ENDPOINTS_ADAPTER.validate_python(
|
||||
data.get("supported_endpoints", [])
|
||||
)
|
||||
self.supported_endpoints = data.get("supported_endpoints", [])
|
||||
self.provider_info: ProviderSpecificModelInfo = (
|
||||
_PROVIDER_INFO_ADAPTER.validate_python(data["provider_info"]) if "provider_info" in data else {}
|
||||
)
|
||||
|
|
@ -82,19 +79,16 @@ class JSONProviderRegistry:
|
|||
return next((provider for provider in cls._providers.values() if provider.base_url == base_url), None)
|
||||
|
||||
@classmethod
|
||||
def supports_responses_api(cls, slug: str) -> bool:
|
||||
"""Check if a JSON provider supports the Responses API"""
|
||||
def supports_endpoint(cls, slug: str, endpoint: str) -> bool:
|
||||
provider: Final = cls._providers.get(slug)
|
||||
if provider is None:
|
||||
return False
|
||||
return "/v1/responses" in provider.supported_endpoints
|
||||
return endpoint in provider.supported_endpoints
|
||||
|
||||
@classmethod
|
||||
def supports_embeddings(cls, slug: str) -> bool:
|
||||
provider: Final = cls._providers.get(slug)
|
||||
if provider is None:
|
||||
return False
|
||||
return "/v1/embeddings" in provider.supported_endpoints
|
||||
def supports_responses_api(cls, slug: str) -> bool:
|
||||
"""Check if a JSON provider supports the Responses API"""
|
||||
return cls.supports_endpoint(slug, "/v1/responses")
|
||||
|
||||
@classmethod
|
||||
def list_providers(cls) -> list:
|
||||
|
|
|
|||
|
|
@ -6911,7 +6911,7 @@ def embedding(
|
|||
custom_llm_provider == "openai_like"
|
||||
or custom_llm_provider == "llamafile"
|
||||
or custom_llm_provider == "lm_studio"
|
||||
or JSONProviderRegistry.supports_embeddings(custom_llm_provider)
|
||||
or JSONProviderRegistry.supports_endpoint(custom_llm_provider, "/v1/embeddings")
|
||||
):
|
||||
api_base = api_base or litellm.api_base or get_secret_str("OPENAI_LIKE_API_BASE")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue