mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
Fix Jina embedding credential fallback
Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>
This commit is contained in:
parent
3b78a3a545
commit
ebe0cd901d
2 changed files with 25 additions and 2 deletions
|
|
@ -85,8 +85,7 @@ class JinaAIEmbeddingConfig(BaseEmbeddingConfig):
|
|||
) # type: ignore
|
||||
dynamic_api_key = api_key or (
|
||||
get_secret_str("JINA_AI_API_KEY")
|
||||
or get_secret_str("JINA_AI_API_KEY")
|
||||
or get_secret_str("JINA_AI_API_KEY")
|
||||
or get_secret_str("JINA_API_KEY")
|
||||
or get_secret_str("JINA_AI_TOKEN")
|
||||
)
|
||||
return LlmProviders.JINA_AI.value, api_base, dynamic_api_key
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ sys.path.insert(
|
|||
0, os.path.abspath("../../../../../..")
|
||||
) # Adds the parent directory to the system path
|
||||
|
||||
import litellm.llms.jina_ai.embedding.transformation as jina_embedding_transformation
|
||||
from litellm.llms.jina_ai.embedding.transformation import JinaAIEmbeddingConfig
|
||||
|
||||
|
||||
|
|
@ -26,6 +27,29 @@ class TestJinaAIEmbeddingTransform:
|
|||
)
|
||||
assert result == {"dimensions": 1024}
|
||||
|
||||
def test_provider_info_uses_jina_api_key_alias(self, monkeypatch):
|
||||
"""Test provider info resolves the shared Jina credential alias"""
|
||||
|
||||
def fake_get_secret_str(secret_name):
|
||||
if secret_name == "JINA_API_KEY":
|
||||
return "test-jina-key"
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(
|
||||
jina_embedding_transformation, "get_secret_str", fake_get_secret_str
|
||||
)
|
||||
|
||||
custom_llm_provider, api_base, dynamic_api_key = (
|
||||
self.config._get_openai_compatible_provider_info(
|
||||
api_base=None,
|
||||
api_key=None,
|
||||
)
|
||||
)
|
||||
|
||||
assert custom_llm_provider == "jina_ai"
|
||||
assert api_base == "https://api.jina.ai/v1"
|
||||
assert dynamic_api_key == "test-jina-key"
|
||||
|
||||
def test_transform_embedding_request_text_input(self):
|
||||
"""Test transformation of a standard text embedding request"""
|
||||
input_data = ["hello world", "hello world again"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue