mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
fix(databricks/chat/transformation.py): handle empty headers case
This commit is contained in:
parent
a771d17794
commit
af9db827fc
2 changed files with 4 additions and 4 deletions
|
@ -67,7 +67,7 @@ class DatabricksBase:
|
||||||
custom_endpoint: Optional[bool],
|
custom_endpoint: Optional[bool],
|
||||||
headers: Optional[dict],
|
headers: Optional[dict],
|
||||||
) -> Tuple[str, 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:
|
if custom_endpoint is not None:
|
||||||
raise DatabricksException(
|
raise DatabricksException(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
|
|
|
@ -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
|
# Simulate that the databricks SDK is not installed
|
||||||
monkeypatch.setitem(sys.modules, "databricks.sdk", None)
|
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:
|
if set_base:
|
||||||
monkeypatch.setenv(
|
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",
|
model="databricks/dbrx-instruct-071224",
|
||||||
messages=[{"role": "user", "content": "How are you?"}],
|
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:
|
with pytest.raises(BadRequestError) as exc:
|
||||||
litellm.embedding(
|
litellm.embedding(
|
||||||
model="databricks/bge-12312",
|
model="databricks/bge-12312",
|
||||||
input=["Hello", "World"],
|
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):
|
def test_completions_with_sync_http_handler(monkeypatch):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue