fix(databricks/chat/transformation.py): handle empty headers case

This commit is contained in:
Krrish Dholakia 2025-04-05 08:33:56 -07:00
parent a771d17794
commit af9db827fc
2 changed files with 4 additions and 4 deletions

View file

@ -67,7 +67,7 @@ class DatabricksBase:
custom_endpoint: Optional[bool],
headers: Optional[dict],
) -> Tuple[str, dict]:
if api_key is None and headers is None:
if api_key is None and not headers: # handle empty headers
if custom_endpoint is not None:
raise DatabricksException(
status_code=400,

View file

@ -216,7 +216,7 @@ def test_throws_if_api_base_or_api_key_not_set_without_databricks_sdk(
# Simulate that the databricks SDK is not installed
monkeypatch.setitem(sys.modules, "databricks.sdk", None)
err_msg = "the Databricks base URL and API key are not set"
err_msg = ["the Databricks base URL and API key are not set", "Missing API Key"]
if set_base:
monkeypatch.setenv(
@ -237,14 +237,14 @@ def test_throws_if_api_base_or_api_key_not_set_without_databricks_sdk(
model="databricks/dbrx-instruct-071224",
messages=[{"role": "user", "content": "How are you?"}],
)
assert err_msg in str(exc)
assert any(msg in str(exc) for msg in err_msg)
with pytest.raises(BadRequestError) as exc:
litellm.embedding(
model="databricks/bge-12312",
input=["Hello", "World"],
)
assert err_msg in str(exc)
assert any(msg in str(exc) for msg in err_msg)
def test_completions_with_sync_http_handler(monkeypatch):