mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
fix(proxy): skip OAuth provider logins when scanning deployments for Vertex AI Live
This commit is contained in:
parent
40fa17eb06
commit
c5f7118770
2 changed files with 32 additions and 1 deletions
|
|
@ -50,6 +50,7 @@ from litellm.constants import (
|
|||
from litellm.exceptions import BlockedPiiEntityError, GuardrailRaisedException
|
||||
from litellm.integrations.custom_guardrail import guardrail_request_data_with_streaming, is_guardrail_intervention
|
||||
from litellm.litellm_core_utils.aws_partition import get_aws_dns_suffix
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import resolve_model_and_provider_for_metadata
|
||||
from litellm.llms.anthropic.common_utils import AnthropicModelInfo, merge_anthropic_beta_headers
|
||||
from litellm.llms.azure.passthrough.transformation import (
|
||||
foreign_azure_deployment,
|
||||
|
|
@ -3927,7 +3928,7 @@ def _vertex_upstream_model(deployment: DeploymentTypedDict) -> str | None:
|
|||
return None
|
||||
upstream: Final = litellm_params["model"]
|
||||
try:
|
||||
_, provider, _, _ = litellm.get_llm_provider(
|
||||
_, provider = resolve_model_and_provider_for_metadata(
|
||||
model=upstream, custom_llm_provider=litellm_params.get("custom_llm_provider")
|
||||
)
|
||||
except litellm.exceptions.BadRequestError:
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from contextlib import ExitStack, contextmanager
|
|||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from types import MappingProxyType, ModuleType, SimpleNamespace
|
||||
from typing import Final, Optional, cast
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
|
@ -8055,6 +8056,35 @@ async def test_vertex_live_full_path_whose_every_name_is_taken_by_another_model_
|
|||
assert (_policy_close_reason(websocket) is None) is reaches_vertex
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_vertex_live_setup_frame_never_refreshes_the_token_of_a_chatgpt_group_on_the_same_proxy(
|
||||
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||
):
|
||||
(tmp_path / "auth.json").write_text(
|
||||
json.dumps({"access_token": "expired", "refresh_token": "refresh", "expires_at": 0})
|
||||
)
|
||||
monkeypatch.setenv("CHATGPT_TOKEN_DIR", str(tmp_path))
|
||||
monkeypatch.delenv("CHATGPT_AUTH_FILE", raising=False)
|
||||
llm_router: Final = litellm.Router(
|
||||
model_list=[
|
||||
{"model_name": "codex", "litellm_params": {"model": "chatgpt/gpt-5.4"}},
|
||||
{"model_name": "native-audio", "litellm_params": {"model": f"vertex_ai/{VERTEX_LIVE_GROUP}"}},
|
||||
]
|
||||
)
|
||||
|
||||
with respx.mock(assert_all_called=False) as transport:
|
||||
outbound: Final = transport.route().respond(500)
|
||||
websocket, upstream_ws = await _run_vertex_live_gated_passthrough(
|
||||
[_setup_frame("native-audio")],
|
||||
UserAPIKeyAuth(token="hashed", models=["native-audio"]),
|
||||
llm_router=llm_router,
|
||||
)
|
||||
|
||||
assert not outbound.called
|
||||
upstream_ws.send.assert_awaited_once()
|
||||
assert _policy_close_reason(websocket) is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"valid_token",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue