diff --git a/litellm/litellm_core_utils/realtime_streaming.py b/litellm/litellm_core_utils/realtime_streaming.py index 8df41aea4a3..e2988cbd856 100644 --- a/litellm/litellm_core_utils/realtime_streaming.py +++ b/litellm/litellm_core_utils/realtime_streaming.py @@ -18,13 +18,21 @@ from litellm.types.realtime import ALL_DELTA_TYPES from .litellm_logging import Logging as LiteLLMLogging if TYPE_CHECKING: + from typing import Protocol from websockets.asyncio.client import ClientConnection + class WSProtocol(Protocol): + async def send(self, data: str) -> None: ... + async def recv(self, **kwargs: Any) -> Any: ... + async def close(self) -> None: ... + + CLIENT_CONNECTION_CLASS = ClientConnection else: CLIENT_CONNECTION_CLASS = Any # Create a thread pool with a maximum of 10 threads + executor = concurrent.futures.ThreadPoolExecutor(max_workers=10) DefaultLoggedRealTimeEventTypes = [ @@ -594,3 +602,4 @@ class RealTimeStreaming: await forward_task except asyncio.CancelledError: pass + diff --git a/tests/mcp_tests/test_proxy_mcp_e2e.py b/tests/mcp_tests/test_proxy_mcp_e2e.py index 5aff63a51ef..28127dd9eae 100644 --- a/tests/mcp_tests/test_proxy_mcp_e2e.py +++ b/tests/mcp_tests/test_proxy_mcp_e2e.py @@ -293,3 +293,4 @@ class TestProxyMcpStatelessBehavior: text_b = getattr(result_b.content[0], "text", None) assert text_b == "300" +