mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix req changes
This commit is contained in:
parent
25fa9af272
commit
99210e9867
2 changed files with 24 additions and 31 deletions
|
|
@ -2162,22 +2162,24 @@ async def _run_background_health_check():
|
|||
"Error in shared health check, falling back to direct health check: %s",
|
||||
str(e),
|
||||
)
|
||||
healthy_endpoints, unhealthy_endpoints = (
|
||||
await _run_direct_health_check_with_instrumentation(
|
||||
_llm_model_list,
|
||||
health_check_details,
|
||||
health_check_concurrency,
|
||||
instrumentation_context,
|
||||
)
|
||||
)
|
||||
else:
|
||||
healthy_endpoints, unhealthy_endpoints = (
|
||||
await _run_direct_health_check_with_instrumentation(
|
||||
(
|
||||
healthy_endpoints,
|
||||
unhealthy_endpoints,
|
||||
) = await _run_direct_health_check_with_instrumentation(
|
||||
_llm_model_list,
|
||||
health_check_details,
|
||||
health_check_concurrency,
|
||||
instrumentation_context,
|
||||
)
|
||||
else:
|
||||
(
|
||||
healthy_endpoints,
|
||||
unhealthy_endpoints,
|
||||
) = await _run_direct_health_check_with_instrumentation(
|
||||
_llm_model_list,
|
||||
health_check_details,
|
||||
health_check_concurrency,
|
||||
instrumentation_context,
|
||||
)
|
||||
|
||||
# Update the global variable with the health check results
|
||||
|
|
@ -7125,13 +7127,6 @@ async def audio_speech(
|
|||
"audio/wav" # Gemini TTS returns WAV format after conversion
|
||||
)
|
||||
|
||||
# Proxy-level success hook (e.g. Prometheus litellm_proxy_total_requests_metric)
|
||||
await proxy_logging_obj.post_call_success_hook(
|
||||
data=data,
|
||||
response=response, # type: ignore[arg-type]
|
||||
user_api_key_dict=user_api_key_dict,
|
||||
)
|
||||
|
||||
return StreamingResponse(
|
||||
_audio_speech_chunk_generator(response), # type: ignore[arg-type]
|
||||
media_type=media_type,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
"""
|
||||
Regression tests: proxy /v1/audio/speech (TTS) must call proxy-level success/failure
|
||||
hooks so Prometheus metrics (litellm_proxy_total_requests_metric, litellm_proxy_failed_requests_metric)
|
||||
and other callbacks see TTS requests.
|
||||
"""
|
||||
import asyncio
|
||||
import os
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
|
@ -10,7 +5,6 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
|||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
# Import after path setup so proxy_server is loadable
|
||||
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
|
||||
from litellm.proxy.proxy_server import app, initialize
|
||||
|
||||
|
|
@ -21,7 +15,7 @@ def _mock_user_api_key_auth():
|
|||
|
||||
|
||||
def _make_mock_tts_response():
|
||||
"""Mock response for handler: llm_call = await route_request(), response = await llm_call, then _audio_speech_chunk_generator does await response.aiter_bytes() and async for chunk in it."""
|
||||
"""Mock response that simulates HttpxBinaryResponseContent with aiter_bytes."""
|
||||
|
||||
async def _chunks():
|
||||
yield b"\xff\xfb"
|
||||
|
|
@ -55,8 +49,15 @@ def client_no_auth():
|
|||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.retry(retries=0)
|
||||
async def test_audio_speech_success_calls_post_call_success_hook(client_no_auth):
|
||||
"""TTS success path must call proxy_logging_obj.post_call_success_hook (Prometheus total requests)."""
|
||||
async def test_audio_speech_success_does_not_call_post_call_success_hook(
|
||||
client_no_auth,
|
||||
):
|
||||
"""TTS success path must NOT call post_call_success_hook.
|
||||
|
||||
TTS returns a streaming binary response (HttpxBinaryResponseContent) which
|
||||
is not in LLMResponseTypes. Prometheus metrics for successful requests are
|
||||
tracked at the litellm level via async_log_success_event, not here.
|
||||
"""
|
||||
mock_success_hook = AsyncMock()
|
||||
mock_failure_hook = AsyncMock()
|
||||
mock_pre_call = AsyncMock(side_effect=lambda *, data, **kw: data)
|
||||
|
|
@ -91,11 +92,8 @@ async def test_audio_speech_success_calls_post_call_success_hook(client_no_auth)
|
|||
app.dependency_overrides = original_overrides
|
||||
|
||||
assert response.status_code == 200
|
||||
mock_success_hook.assert_awaited_once()
|
||||
mock_success_hook.assert_not_called()
|
||||
mock_failure_hook.assert_not_called()
|
||||
# Ensure we passed through the right call type
|
||||
call_kw = mock_success_hook.call_args.kwargs
|
||||
assert "data" in call_kw and "user_api_key_dict" in call_kw
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue