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()
|
||||
|
||||
|
||||
def get_response_body(response: httpx.Response):
|
||||
def get_response_body(response: httpx.Response) -> Optional[dict]:
|
||||
try:
|
||||
return response.json()
|
||||
except Exception:
|
||||
return response.text
|
||||
return None
|
||||
|
||||
|
||||
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()
|
||||
|
||||
## 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()
|
||||
await pass_through_endpoint_logging.pass_through_async_success_handler(
|
||||
httpx_response=response,
|
||||
response_body=response_body,
|
||||
url_route=str(url),
|
||||
result="",
|
||||
start_time=start_time,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue