forked from phoenix/litellm-mirror
fix get_response_body
This commit is contained in:
parent
bb7fe53bc5
commit
9f916636e1
1 changed files with 5 additions and 3 deletions
|
@ -45,11 +45,11 @@ router = APIRouter()
|
||||||
pass_through_endpoint_logging = PassThroughEndpointLogging()
|
pass_through_endpoint_logging = PassThroughEndpointLogging()
|
||||||
|
|
||||||
|
|
||||||
def get_response_body(response: httpx.Response):
|
def get_response_body(response: httpx.Response) -> Optional[dict]:
|
||||||
try:
|
try:
|
||||||
return response.json()
|
return response.json()
|
||||||
except Exception:
|
except Exception:
|
||||||
return response.text
|
return None
|
||||||
|
|
||||||
|
|
||||||
async def set_env_variables_in_header(custom_headers: Optional[dict]) -> Optional[dict]:
|
async def set_env_variables_in_header(custom_headers: Optional[dict]) -> Optional[dict]:
|
||||||
|
@ -519,10 +519,12 @@ async def pass_through_request( # noqa: PLR0915
|
||||||
content = await response.aread()
|
content = await response.aread()
|
||||||
|
|
||||||
## LOG SUCCESS
|
## LOG SUCCESS
|
||||||
passthrough_logging_payload["response_body"] = get_response_body(response)
|
response_body: Optional[dict] = get_response_body(response)
|
||||||
|
passthrough_logging_payload["response_body"] = response_body
|
||||||
end_time = datetime.now()
|
end_time = datetime.now()
|
||||||
await pass_through_endpoint_logging.pass_through_async_success_handler(
|
await pass_through_endpoint_logging.pass_through_async_success_handler(
|
||||||
httpx_response=response,
|
httpx_response=response,
|
||||||
|
response_body=response_body,
|
||||||
url_route=str(url),
|
url_route=str(url),
|
||||||
result="",
|
result="",
|
||||||
start_time=start_time,
|
start_time=start_time,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue