mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(lemonade): respect api_key and LEMONADE_API_KEY env var in provider info
_get_openai_compatible_provider_info hardcoded key = "lemonade" regardless of any api_key passed by the caller or set in the environment. Lemonade server now supports API key authentication, so use the standard priority chain: passed api_key → LEMONADE_API_KEY env var → "lemonade" sentinel. Closes #25363
This commit is contained in:
parent
934ecdca78
commit
139824d121
2 changed files with 28 additions and 4 deletions
|
|
@ -110,8 +110,7 @@ class LemonadeChatConfig(OpenAILikeChatConfig):
|
|||
or get_secret_str("LEMONADE_API_BASE")
|
||||
or "http://localhost:8000/api/v1"
|
||||
) # type: ignore
|
||||
# Lemonade doesn't check the key
|
||||
key = "lemonade"
|
||||
key = api_key or get_secret_str("LEMONADE_API_KEY") or "lemonade"
|
||||
return api_base, key
|
||||
|
||||
def transform_response(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ def test_get_openai_compatible_provider_info():
|
|||
)
|
||||
|
||||
assert api_base == "http://localhost:8000/api/v1"
|
||||
assert key == "lemonade"
|
||||
assert key == "lemonade" # falls back to sentinel when no key provided
|
||||
|
||||
|
||||
def test_get_openai_compatible_provider_info_with_custom_base():
|
||||
|
|
@ -50,7 +50,32 @@ def test_get_openai_compatible_provider_info_with_custom_base():
|
|||
)
|
||||
|
||||
assert api_base == custom_api_base
|
||||
assert key == "lemonade"
|
||||
assert key == "lemonade" # falls back to sentinel when no key provided
|
||||
|
||||
|
||||
def test_get_openai_compatible_provider_info_with_api_key():
|
||||
"""Test that a passed api_key is respected"""
|
||||
config = LemonadeChatConfig()
|
||||
|
||||
api_base, key = config._get_openai_compatible_provider_info(
|
||||
api_base=None,
|
||||
api_key="my-secret-key",
|
||||
)
|
||||
|
||||
assert key == "my-secret-key"
|
||||
|
||||
|
||||
def test_get_openai_compatible_provider_info_with_env_key(monkeypatch):
|
||||
"""Test that LEMONADE_API_KEY env var is used when no api_key is passed"""
|
||||
monkeypatch.setenv("LEMONADE_API_KEY", "env-secret-key")
|
||||
config = LemonadeChatConfig()
|
||||
|
||||
api_base, key = config._get_openai_compatible_provider_info(
|
||||
api_base=None,
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert key == "env-secret-key"
|
||||
|
||||
|
||||
def test_transform_response():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue