mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix: patch litellm.api_base in test and add branch-order guard comment
Addresses review feedback: - Reset litellm.api_base to None in get_api_base tests for isolation - Add comment clarifying why /projects/ branch must precede services.ai.azure.com Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8ecd97517d
commit
7358c0bf7c
2 changed files with 9 additions and 4 deletions
|
|
@ -114,9 +114,11 @@ class AzureAIResponsesAPIConfig(OpenAIResponsesAPIConfig):
|
|||
query_params["api-version"] = api_version
|
||||
|
||||
# Build the responses endpoint path.
|
||||
# Check /projects/ first: project-based endpoints under
|
||||
# services.ai.azure.com need /openai/v1/responses, which differs
|
||||
# from the non-project services.ai.azure.com path (/models/responses).
|
||||
# IMPORTANT: The /projects/ check MUST come before the general
|
||||
# services.ai.azure.com check (_should_use_api_key_header), because
|
||||
# project URLs also contain that domain. If we checked
|
||||
# services.ai.azure.com first, project URLs would incorrectly get
|
||||
# the /models/responses path instead of /openai/v1/responses.
|
||||
if "/projects/" in api_base:
|
||||
new_url = _add_path_to_api_base(
|
||||
api_base=api_base, ending_path="/openai/v1/responses"
|
||||
|
|
|
|||
|
|
@ -125,8 +125,11 @@ class TestAzureAIResponsesURL:
|
|||
)
|
||||
assert url == "https://custom-proxy.example.com/v1/responses"
|
||||
|
||||
def test_missing_api_base_raises(self):
|
||||
def test_missing_api_base_raises(self, monkeypatch):
|
||||
"""ValueError raised when api_base is None and no env var set."""
|
||||
# Patch litellm.api_base to None so the test is isolated from
|
||||
# any global state set by other tests or config.
|
||||
monkeypatch.setattr(litellm, "api_base", None)
|
||||
config = AzureAIResponsesAPIConfig()
|
||||
with patch.dict(os.environ, {}, clear=False):
|
||||
# Ensure env var is not set
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue