mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
refac
This commit is contained in:
parent
5b3eae3855
commit
1bc9711afd
1 changed files with 110 additions and 100 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue