mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
Merge b49032fc80 into 2f0f0685c0
This commit is contained in:
commit
4d9a141e38
4 changed files with 55 additions and 0 deletions
|
|
@ -596,6 +596,9 @@ LITELLM_CHAT_PROVIDERS: Final = [
|
|||
"gdc",
|
||||
"xai",
|
||||
"custom_openai",
|
||||
"byteplus",
|
||||
"digitalocean",
|
||||
"siliconflow",
|
||||
"text-completion-openai",
|
||||
"cohere",
|
||||
"cohere_chat",
|
||||
|
|
@ -930,6 +933,9 @@ openai_compatible_providers: Final[list] = [
|
|||
"cometapi",
|
||||
"clarifai",
|
||||
"docker_model_runner",
|
||||
"byteplus",
|
||||
"digitalocean",
|
||||
"siliconflow",
|
||||
"ragflow",
|
||||
"pinstripes", # Pinstripes - JSON-configured provider
|
||||
"darkbloom",
|
||||
|
|
@ -961,6 +967,9 @@ openai_text_completion_compatible_providers: Final[list] = [ # providers that s
|
|||
"lambda_ai",
|
||||
"hyperbolic",
|
||||
"wandb",
|
||||
"byteplus",
|
||||
"digitalocean",
|
||||
"siliconflow",
|
||||
]
|
||||
_openai_like_providers: Final[list] = [
|
||||
"predibase",
|
||||
|
|
|
|||
|
|
@ -6272,6 +6272,12 @@ def embedding(
|
|||
or custom_llm_provider == "together_ai"
|
||||
or custom_llm_provider == "nvidia_nim"
|
||||
or custom_llm_provider == "litellm_proxy"
|
||||
or custom_llm_provider == "byteplus"
|
||||
or custom_llm_provider == "digitalocean"
|
||||
or custom_llm_provider == "siliconflow"
|
||||
or custom_llm_provider == "deepinfra"
|
||||
or custom_llm_provider == "nscale"
|
||||
or custom_llm_provider == "novita"
|
||||
or (model in litellm.open_ai_embedding_models and custom_llm_provider is None)
|
||||
):
|
||||
api_base = (
|
||||
|
|
|
|||
|
|
@ -3768,6 +3768,9 @@ class LlmProviders(str, Enum):
|
|||
ANTHROPIC = "anthropic"
|
||||
ANTHROPIC_TEXT = "anthropic_text"
|
||||
BYTEZ = "bytez"
|
||||
BYTEPLUS = "byteplus"
|
||||
DIGITALOCEAN = "digitalocean"
|
||||
SILICONFLOW = "siliconflow"
|
||||
REPLICATE = "replicate"
|
||||
REDUCTO = "reducto"
|
||||
RUNWAYML = "runwayml"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
import litellm
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"provider",
|
||||
["byteplus", "digitalocean", "siliconflow", "deepinfra", "nscale", "novita"],
|
||||
)
|
||||
def test_openai_compatible_provider_embedding_dispatch(provider):
|
||||
mock_response = MagicMock()
|
||||
mock_response.parse.return_value = MagicMock(
|
||||
model_dump=lambda: {
|
||||
"data": [{"embedding": [0.1, 0.2, 0.3], "index": 0}],
|
||||
"model": "test-embedding",
|
||||
"object": "list",
|
||||
"usage": {"prompt_tokens": 1, "total_tokens": 1},
|
||||
}
|
||||
)
|
||||
mock_response.headers = {}
|
||||
|
||||
with patch("litellm.llms.openai.openai.OpenAIChatCompletion._get_openai_client") as mock_get_client:
|
||||
mock_client = MagicMock()
|
||||
mock_get_client.return_value = mock_client
|
||||
mock_client.embeddings.with_raw_response.create.return_value = mock_response
|
||||
|
||||
response = litellm.embedding(
|
||||
model=f"{provider}/test-embedding",
|
||||
input="Hello world",
|
||||
api_key="test-key",
|
||||
api_base="http://test.example/v1",
|
||||
)
|
||||
|
||||
assert response.data[0]["embedding"] == [0.1, 0.2, 0.3]
|
||||
assert mock_client.embeddings.with_raw_response.create.called
|
||||
Loading…
Add table
Reference in a new issue