From 7e24a5bea0fbaa9be13f1bd6bf052979e637c22f Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 21 Apr 2025 18:27:11 -0700 Subject: [PATCH] test_assistants_passthrough_logging --- .../pass_through_endpoints.py | 1 + .../pass_through_endpoints.py | 16 ++++++++++++++++ .../test_custom_logger_passthrough.py | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index ba99e0e944..2fbedaeb22 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -534,6 +534,7 @@ async def pass_through_request( # noqa: PLR0915 passthrough_logging_payload = PassthroughStandardLoggingPayload( url=str(url), request_body=_parsed_body, + request_method=getattr(request, "method", None), ) kwargs = _init_kwargs_for_pass_through_endpoint( user_api_key_dict=user_api_key_dict, diff --git a/litellm/types/passthrough_endpoints/pass_through_endpoints.py b/litellm/types/passthrough_endpoints/pass_through_endpoints.py index 59047a630d..ef4e2a0a25 100644 --- a/litellm/types/passthrough_endpoints/pass_through_endpoints.py +++ b/litellm/types/passthrough_endpoints/pass_through_endpoints.py @@ -14,5 +14,21 @@ class PassthroughStandardLoggingPayload(TypedDict, total=False): """ url: str + """ + The full url of the request + """ + + request_method: Optional[str] + """ + The method of the request + "GET", "POST", "PUT", "DELETE", etc. + """ + request_body: Optional[dict] + """ + The body of the request + """ response_body: Optional[dict] # only tracked for non-streaming responses + """ + The body of the response + """ diff --git a/tests/pass_through_unit_tests/test_custom_logger_passthrough.py b/tests/pass_through_unit_tests/test_custom_logger_passthrough.py index fabd798791..4e37240643 100644 --- a/tests/pass_through_unit_tests/test_custom_logger_passthrough.py +++ b/tests/pass_through_unit_tests/test_custom_logger_passthrough.py @@ -38,12 +38,13 @@ async def test_assistants_passthrough_logging(): "tools": [{"type": "code_interpreter"}], "model": "gpt-4o" } + TARGET_METHOD = "POST" result = await pass_through_request( request=Request( scope={ "type": "http", - "method": "POST", + "method": TARGET_METHOD, "path": "/v1/assistants", "query_string": b"", "headers": [ @@ -86,5 +87,8 @@ async def test_assistants_passthrough_logging(): client_facing_response_body = json.loads(result.body) assert passthrough_logging_payload["response_body"] == client_facing_response_body + # assert that the request method is correct + assert passthrough_logging_payload["request_method"] == TARGET_METHOD +