This commit is contained in:
Timothy Jaeryang Baek 2025-09-05 17:28:05 +04:00
parent 5b3eae3855
commit 1bc9711afd

View file

@ -1284,7 +1284,11 @@ async def process_chat_response(
# Non-streaming response
if not isinstance(response, StreamingResponse):
if event_emitter:
try:
if isinstance(response, dict) or isinstance(response, JSONResponse):
if isinstance(response, list) and len(response) == 1:
# If the response is a single-item list, unwrap it #17213
response = response[0]
if isinstance(response, JSONResponse) and isinstance(
response.body, bytes
@ -1292,7 +1296,9 @@ async def process_chat_response(
try:
response_data = json.loads(response.body.decode("utf-8"))
except json.JSONDecodeError:
response_data = {"error": {"detail": "Invalid JSON response"}}
response_data = {
"error": {"detail": "Invalid JSON response"}
}
else:
response_data = response
@ -1403,6 +1409,10 @@ async def process_chat_response(
status_code=response.status_code,
)
except Exception as e:
log.debug(f"Error occurred while processing request: {e}")
pass
return response
else:
if events and isinstance(events, list) and isinstance(response, dict):