mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-28 06:23:07 +00:00
Merge 61e4266138 into f2118fc767
This commit is contained in:
commit
a0f64eb918
6 changed files with 64 additions and 22 deletions
|
|
@ -112,19 +112,8 @@ class VertexBase:
|
|||
supported_regions: Final = model_info.get("supported_regions")
|
||||
|
||||
if supported_regions and len(supported_regions) > 0:
|
||||
# If user didn't specify region, use the first supported region
|
||||
if vertex_region is None:
|
||||
return supported_regions[0]
|
||||
# If user specified a region not supported by this model, override it
|
||||
if vertex_region not in supported_regions:
|
||||
verbose_logger.warning(
|
||||
"Vertex AI model '%s' does not support region '%s' (supported: %s). Routing to '%s'.",
|
||||
model,
|
||||
vertex_region,
|
||||
supported_regions,
|
||||
supported_regions[0],
|
||||
)
|
||||
return supported_regions[0]
|
||||
return vertex_region
|
||||
return vertex_region or "us-central1"
|
||||
|
||||
|
|
|
|||
|
|
@ -30216,6 +30216,11 @@
|
|||
"supported_output_modalities": [
|
||||
"text"
|
||||
],
|
||||
"supported_regions": [
|
||||
"global",
|
||||
"us",
|
||||
"eu"
|
||||
],
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_parallel_function_calling": true,
|
||||
|
|
@ -30284,6 +30289,11 @@
|
|||
"supported_output_modalities": [
|
||||
"text"
|
||||
],
|
||||
"supported_regions": [
|
||||
"global",
|
||||
"us",
|
||||
"eu"
|
||||
],
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_minimal_reasoning_effort": false,
|
||||
|
|
@ -76358,6 +76368,11 @@
|
|||
"supported_output_modalities": [
|
||||
"text"
|
||||
],
|
||||
"supported_regions": [
|
||||
"global",
|
||||
"us",
|
||||
"eu"
|
||||
],
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_minimal_reasoning_effort": false,
|
||||
|
|
|
|||
|
|
@ -30216,6 +30216,11 @@
|
|||
"supported_output_modalities": [
|
||||
"text"
|
||||
],
|
||||
"supported_regions": [
|
||||
"global",
|
||||
"us",
|
||||
"eu"
|
||||
],
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_parallel_function_calling": true,
|
||||
|
|
@ -30284,6 +30289,11 @@
|
|||
"supported_output_modalities": [
|
||||
"text"
|
||||
],
|
||||
"supported_regions": [
|
||||
"global",
|
||||
"us",
|
||||
"eu"
|
||||
],
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_minimal_reasoning_effort": false,
|
||||
|
|
@ -76358,6 +76368,11 @@
|
|||
"supported_output_modalities": [
|
||||
"text"
|
||||
],
|
||||
"supported_regions": [
|
||||
"global",
|
||||
"us",
|
||||
"eu"
|
||||
],
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_minimal_reasoning_effort": false,
|
||||
|
|
|
|||
|
|
@ -1069,10 +1069,8 @@ def test_get_vertex_url_global_region(stream, expected_endpoint_suffix):
|
|||
[
|
||||
# Model with supported_regions=["global"], no user region -> use "global"
|
||||
({"supported_regions": ["global"]}, None, "global"),
|
||||
# Model with supported_regions=["global"], user passes unsupported region -> override to "global"
|
||||
({"supported_regions": ["global"]}, "us-central1", "global"),
|
||||
# Model with supported_regions=["global"], user passes unsupported region -> override to "global"
|
||||
({"supported_regions": ["global"]}, "europe-west1", "global"),
|
||||
({"supported_regions": ["global"]}, "us-central1", "us-central1"),
|
||||
({"supported_regions": ["global"]}, "europe-west1", "europe-west1"),
|
||||
# Model with supported_regions=["us-west2"], no user region -> use "us-west2"
|
||||
({"supported_regions": ["us-west2"]}, None, "us-west2"),
|
||||
# Model with supported_regions=["us-west2", "us-central1"], user passes supported region -> respect it
|
||||
|
|
@ -1081,11 +1079,10 @@ def test_get_vertex_url_global_region(stream, expected_endpoint_suffix):
|
|||
"us-central1",
|
||||
"us-central1",
|
||||
),
|
||||
# Model with supported_regions=["us-west2", "us-central1"], user passes unsupported region -> override
|
||||
(
|
||||
{"supported_regions": ["us-west2", "us-central1"]},
|
||||
"europe-west1",
|
||||
"us-west2",
|
||||
"europe-west1",
|
||||
),
|
||||
# No model_cost entry, no user region -> default us-central1
|
||||
({}, None, "us-central1"),
|
||||
|
|
@ -1112,6 +1109,32 @@ def test_get_vertex_region_global_only_model(model_cost_entry, vertex_region, ex
|
|||
assert result == expected_region
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", ["gemini-3.7-flash", "gemini-3.8-flash", "gemini-4-argon"])
|
||||
@pytest.mark.parametrize(
|
||||
"vertex_region, expected_region",
|
||||
[
|
||||
(None, "global"),
|
||||
("global", "global"),
|
||||
("us", "us"),
|
||||
("eu", "eu"),
|
||||
("us-central1", "us-central1"),
|
||||
("europe-west1", "europe-west1"),
|
||||
],
|
||||
)
|
||||
def test_gemini_defaults_to_global_and_preserves_explicit_regions(
|
||||
model: str, vertex_region: str | None, expected_region: str
|
||||
) -> None:
|
||||
"""Location availability verified 2026-10-19:
|
||||
|
||||
https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-7-flash
|
||||
https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/3-8-flash
|
||||
https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-argon
|
||||
"""
|
||||
from litellm.llms.vertex_ai.vertex_llm_base import VertexBase
|
||||
|
||||
assert VertexBase.get_vertex_region(vertex_region=vertex_region, model=model) == expected_region
|
||||
|
||||
|
||||
def test_vertex_filter_format_uri():
|
||||
import json
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class TestVertexBaseGetVertexRegionGemma:
|
|||
)
|
||||
assert result == "global"
|
||||
|
||||
def test_global_model_with_unsupported_user_region_overrides(self):
|
||||
def test_global_model_preserves_explicit_user_region(self):
|
||||
vertex_base = VertexBase()
|
||||
|
||||
with patch.dict(
|
||||
|
|
@ -121,7 +121,7 @@ class TestVertexBaseGetVertexRegionGemma:
|
|||
vertex_region="us-central1",
|
||||
model="google/gemma-4-26b-a4b-it-maas",
|
||||
)
|
||||
assert result == "global"
|
||||
assert result == "us-central1"
|
||||
|
||||
|
||||
class TestCreateVertexURLGemma:
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ class TestVertexBaseGetVertexRegion:
|
|||
)
|
||||
assert result == "global"
|
||||
|
||||
def test_global_model_with_unsupported_user_region_overrides(self):
|
||||
"""Test that unsupported user region is overridden for global-only models."""
|
||||
def test_global_model_preserves_explicit_user_region(self):
|
||||
"""Test that an explicit user region is not silently broadened."""
|
||||
vertex_base = VertexBase()
|
||||
|
||||
with patch.dict(
|
||||
|
|
@ -81,7 +81,7 @@ class TestVertexBaseGetVertexRegion:
|
|||
vertex_region="us-central1",
|
||||
model="qwen/qwen3-next-80b-a3b-instruct-maas",
|
||||
)
|
||||
assert result == "global"
|
||||
assert result == "us-central1"
|
||||
|
||||
def test_non_global_model_uses_provided_region(self):
|
||||
"""Test that non-global models use the provided region."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue