mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
* feat: add Bespoke Nimble gateway and OSS classifier support * feat: accept Ollama's nimble model name for the Bespoke provider * test: exempt the POST-only bespoke decisions route from the all-methods check test_pass_through_routes_support_all_methods requires every built-in pass-through route to accept every HTTP method unless it is listed in PROTOCOL_CONSTRAINED_PASS_THROUGH_ROUTES. /bespoke/v1/systemone is POST-only like /laya/v1/systemone, so the test failed at this branch and passed at the merge base. List it alongside Laya. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
from typing import Final
|
|
|
|
import pytest
|
|
|
|
from litellm.llms.oss_decision import OssDecisionProvider, oss_connection, validate_oss_request
|
|
|
|
pytestmark: Final = pytest.mark.parametrize("provider", ["laya", "bespoke"])
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("base", "key", "expected_base", "expected_key"),
|
|
[
|
|
(None, None, "http://decision.test/root", "oss-env-key"),
|
|
("http://custom.test/", None, "http://custom.test", None),
|
|
("http://custom.test/", "explicit-key", "http://custom.test", "explicit-key"),
|
|
],
|
|
)
|
|
def test_oss_credentials_stay_with_their_configured_destination(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
provider: OssDecisionProvider,
|
|
base: str | None,
|
|
key: str | None,
|
|
expected_base: str,
|
|
expected_key: str | None,
|
|
) -> None:
|
|
monkeypatch.setenv(f"{provider.upper()}_API_BASE", "http://decision.test/root/")
|
|
monkeypatch.setenv(f"{provider.upper()}_API_KEY", "oss-env-key")
|
|
monkeypatch.setenv("TYPESAFE_API_KEY", "never-send-this")
|
|
monkeypatch.setenv("NIMBLE_API_KEY", "never-send-nimble-search-key")
|
|
connection: Final = oss_connection(provider, base, key)
|
|
assert (connection.api_base, connection.api_key) == (expected_base, expected_key)
|
|
assert "key" not in repr(connection)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"base",
|
|
["", "ftp://laya.test", "http://user:password@laya.test", "https://laya.test?key=x", "http://laya.test/#x"],
|
|
)
|
|
def test_oss_rejects_ambiguous_server_urls(provider: OssDecisionProvider, base: str) -> None:
|
|
with pytest.raises(ValueError, match=provider):
|
|
oss_connection(provider, base)
|
|
|
|
|
|
def test_oss_missing_server_does_not_fall_back_to_typesafe(
|
|
monkeypatch: pytest.MonkeyPatch, provider: OssDecisionProvider
|
|
) -> None:
|
|
monkeypatch.delenv(f"{provider.upper()}_API_BASE", raising=False)
|
|
monkeypatch.setenv("TYPESAFE_API_BASE", "https://typesafe.test")
|
|
monkeypatch.setenv("NIMBLE_API_BASE", "https://nimble-search.test")
|
|
with pytest.raises(ValueError, match=f"{provider.upper()}_API_BASE"):
|
|
oss_connection(provider)
|
|
|
|
|
|
def test_oss_request_accepts_the_name_ollama_serves_nimble_under_only_for_bespoke(provider: OssDecisionProvider) -> None:
|
|
body: Final = {"model": "nimble"}
|
|
if provider == "bespoke":
|
|
assert validate_oss_request(provider, body) == "nimble"
|
|
return
|
|
with pytest.raises(ValueError, match=f"{provider} model must be one of"):
|
|
validate_oss_request(provider, body)
|