mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
style: apply black formatting
This commit is contained in:
parent
65bed54f28
commit
c9c03ebe9a
2 changed files with 23 additions and 14 deletions
|
|
@ -900,9 +900,11 @@ class ProxyBaseLLMRequestProcessing:
|
|||
"Request received by LiteLLM: payload too large to log (%d bytes, limit %d). Keys: %s",
|
||||
len(_payload_str),
|
||||
MAX_PAYLOAD_SIZE_FOR_DEBUG_LOG,
|
||||
list(self.data.keys())
|
||||
if isinstance(self.data, dict)
|
||||
else type(self.data).__name__,
|
||||
(
|
||||
list(self.data.keys())
|
||||
if isinstance(self.data, dict)
|
||||
else type(self.data).__name__
|
||||
),
|
||||
)
|
||||
else:
|
||||
verbose_proxy_logger.debug(
|
||||
|
|
@ -1181,9 +1183,9 @@ class ProxyBaseLLMRequestProcessing:
|
|||
# aliasing/routing, but the OpenAI-compatible response `model` field should reflect
|
||||
# what the client sent.
|
||||
if requested_model_from_client:
|
||||
self.data[
|
||||
"_litellm_client_requested_model"
|
||||
] = requested_model_from_client
|
||||
self.data["_litellm_client_requested_model"] = (
|
||||
requested_model_from_client
|
||||
)
|
||||
|
||||
# Streaming: attach a closure that fires after all guardrail
|
||||
# end-of-stream blocks complete. CSW.__anext__ stores the
|
||||
|
|
@ -1788,7 +1790,9 @@ class ProxyBaseLLMRequestProcessing:
|
|||
verbose_proxy_logger.debug("inside generator")
|
||||
try:
|
||||
str_so_far = ""
|
||||
async for chunk in proxy_logging_obj.async_post_call_streaming_iterator_hook(
|
||||
async for (
|
||||
chunk
|
||||
) in proxy_logging_obj.async_post_call_streaming_iterator_hook(
|
||||
user_api_key_dict=user_api_key_dict,
|
||||
response=response,
|
||||
request_data=request_data,
|
||||
|
|
@ -2016,9 +2020,9 @@ class ProxyBaseLLMRequestProcessing:
|
|||
|
||||
# Add cache-related fields to **params (handled by Usage.__init__)
|
||||
if cache_creation_input_tokens is not None:
|
||||
usage_kwargs[
|
||||
"cache_creation_input_tokens"
|
||||
] = cache_creation_input_tokens
|
||||
usage_kwargs["cache_creation_input_tokens"] = (
|
||||
cache_creation_input_tokens
|
||||
)
|
||||
if cache_read_input_tokens is not None:
|
||||
usage_kwargs["cache_read_input_tokens"] = cache_read_input_tokens
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
Test client disconnection detection functionality.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
|
@ -13,15 +14,19 @@ async def test_check_request_disconnection_with_disconnect():
|
|||
"""Test that _check_request_disconnection cancels task and sets event when client disconnects."""
|
||||
mock_request = AsyncMock()
|
||||
mock_request.receive.side_effect = [
|
||||
{"type": "http.request"}, # First call
|
||||
{"type": "http.disconnect"} # Second call - disconnect
|
||||
{"type": "http.request"}, # First call
|
||||
{"type": "http.disconnect"}, # Second call - disconnect
|
||||
]
|
||||
|
||||
mock_llm_task = MagicMock() # sync mock so .cancel() doesn't return a coroutine
|
||||
disconnect_event = asyncio.Event()
|
||||
|
||||
with patch("litellm.proxy.common_request_processing.asyncio.sleep", new_callable=AsyncMock):
|
||||
await _check_request_disconnection(mock_request, mock_llm_task, disconnect_event)
|
||||
with patch(
|
||||
"litellm.proxy.common_request_processing.asyncio.sleep", new_callable=AsyncMock
|
||||
):
|
||||
await _check_request_disconnection(
|
||||
mock_request, mock_llm_task, disconnect_event
|
||||
)
|
||||
|
||||
mock_llm_task.cancel.assert_called_once()
|
||||
assert disconnect_event.is_set()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue