mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
refactor(openai): reuse is_openai_backed_api_base for the hosted endpoint check
This commit is contained in:
parent
1d26ee578a
commit
20b3f1efed
1 changed files with 2 additions and 8 deletions
|
|
@ -7,7 +7,6 @@ import os
|
|||
from collections.abc import AsyncIterator, Coroutine, Iterator, Mapping, Sequence
|
||||
from types import MappingProxyType
|
||||
from typing import TYPE_CHECKING, Any, Final, Literal, Optional, cast, overload
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import httpx
|
||||
|
||||
|
|
@ -57,7 +56,7 @@ from litellm.types.utils import (
|
|||
)
|
||||
from litellm.utils import convert_to_model_response_object
|
||||
|
||||
from ..common_utils import OpenAIError
|
||||
from ..common_utils import OpenAIError, is_openai_backed_api_base
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import tiktoken
|
||||
|
|
@ -80,12 +79,7 @@ def targets_openai_hosted_endpoint(custom_llm_provider: str | None, api_base: st
|
|||
resolved_api_base: Final = (
|
||||
api_base or litellm.api_base or os.getenv("OPENAI_BASE_URL") or os.getenv("OPENAI_API_BASE")
|
||||
)
|
||||
if not resolved_api_base:
|
||||
return True
|
||||
hostname: Final = urlparse(resolved_api_base).hostname
|
||||
if hostname is None:
|
||||
return True
|
||||
return hostname == "openai.com" or hostname.endswith(".openai.com")
|
||||
return not resolved_api_base or is_openai_backed_api_base(resolved_api_base)
|
||||
|
||||
|
||||
def translate_developer_role_for_openai_compatible_endpoint(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue