From 7a95132a03d0a40879f9c32016f919a67b8cae5c Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 13 Jul 2024 14:46:56 -0700 Subject: [PATCH] fix(pass_through_endpoints.py): fix client init --- .../proxy/pass_through_endpoints/pass_through_endpoints.py | 4 ++-- litellm/tests/test_pass_through_endpoints.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index 3d17ba0d73..351b19c255 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -23,8 +23,6 @@ from litellm.integrations.custom_logger import CustomLogger from litellm.proxy._types import ProxyException, UserAPIKeyAuth from litellm.proxy.auth.user_api_key_auth import user_api_key_auth -async_client = httpx.AsyncClient() - async def set_env_variables_in_header(custom_headers: dict): """ @@ -277,6 +275,8 @@ async def pass_through_request( call_type="pass_through_endpoint", ) + async_client = httpx.AsyncClient() + response = await async_client.request( method=request.method, url=url, diff --git a/litellm/tests/test_pass_through_endpoints.py b/litellm/tests/test_pass_through_endpoints.py index 9a4431e176..4f52f3d192 100644 --- a/litellm/tests/test_pass_through_endpoints.py +++ b/litellm/tests/test_pass_through_endpoints.py @@ -90,9 +90,8 @@ async def test_pass_through_endpoint_rerank(client): [(True, 0, 429), (True, 1, 200), (False, 0, 401)], ) @pytest.mark.asyncio -async def test_pass_through_endpoint_rpm_limit( - client, auth, expected_error_code, rpm_limit -): +async def test_pass_through_endpoint_rpm_limit(auth, expected_error_code, rpm_limit): + client = TestClient(app) import litellm from litellm.proxy._types import UserAPIKeyAuth from litellm.proxy.proxy_server import ProxyLogging, hash_token, user_api_key_cache