mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
style: drop redundant comments and isolate ANTHROPIC_BASE_URL in url tests
This commit is contained in:
parent
d0a63b472a
commit
1822f01ed7
2 changed files with 1 additions and 7 deletions
|
|
@ -225,8 +225,6 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig):
|
|||
stream: bool | None = None,
|
||||
) -> str:
|
||||
api_base = AnthropicModelInfo.get_api_base(api_base) or "https://api.anthropic.com"
|
||||
# Normalize like OpenAILikeAnthropicMessagesConfig: an api_base that
|
||||
# already ends in /v1 must not become /v1/v1/messages.
|
||||
base = api_base.rstrip("/")
|
||||
if base.endswith("/v1/messages"):
|
||||
return base
|
||||
|
|
|
|||
|
|
@ -13,24 +13,20 @@ def config() -> AnthropicMessagesConfig:
|
|||
@pytest.mark.parametrize(
|
||||
"api_base, expected",
|
||||
[
|
||||
# default when no api_base is configured
|
||||
(None, "https://api.anthropic.com/v1/messages"),
|
||||
# bases without a version suffix
|
||||
("https://host", "https://host/v1/messages"),
|
||||
("https://host/", "https://host/v1/messages"),
|
||||
# bases that already carry /v1 must not become /v1/v1/messages
|
||||
("https://host/v1", "https://host/v1/messages"),
|
||||
("https://host/v1/", "https://host/v1/messages"),
|
||||
("https://api.groq.com/openai/v1", "https://api.groq.com/openai/v1/messages"),
|
||||
# full endpoint passes through untouched
|
||||
("https://host/v1/messages", "https://host/v1/messages"),
|
||||
# provider-prefixed path segments are preserved
|
||||
("https://gateway.example.com/anthropic", "https://gateway.example.com/anthropic/v1/messages"),
|
||||
("https://gateway.example.com/anthropic/v1", "https://gateway.example.com/anthropic/v1/messages"),
|
||||
],
|
||||
)
|
||||
def test_get_complete_url_deduplicates_trailing_v1(config, api_base, expected, monkeypatch):
|
||||
monkeypatch.delenv("ANTHROPIC_API_BASE", raising=False)
|
||||
monkeypatch.delenv("ANTHROPIC_BASE_URL", raising=False)
|
||||
url = config.get_complete_url(
|
||||
api_base=api_base,
|
||||
api_key="sk-test",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue