mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-02 02:12:25 +00:00
fix: errors on Responses API connections are not shown or not kept after a reload (#31439)
With a connection set to the Responses API, when the provider reported a reply as failed, the error showed while streaming but was gone after a reload, leaving an empty reply. Some other provider errors never showed up at all, not even while streaming. Both kinds of error now show up and are still there after a reload, the same as on Chat Completions connections. Fixes #31433
This commit is contained in:
parent
ac00d40e36
commit
9d6b17ffbc
1 changed files with 19 additions and 2 deletions
|
|
@ -933,6 +933,9 @@ def handle_responses_streaming_event(
|
|||
error = data.get('response', {}).get('error', {})
|
||||
return current_output, {'error': error}
|
||||
|
||||
elif event_type == 'error':
|
||||
return current_output, {'error': data}
|
||||
|
||||
else:
|
||||
return current_output, None
|
||||
|
||||
|
|
@ -5113,8 +5116,8 @@ async def streaming_chat_response_handler(response, ctx):
|
|||
'data': data,
|
||||
}
|
||||
)
|
||||
# Check for Responses API events (type field starts with "response.")
|
||||
elif data.get('type', '').startswith('response.'):
|
||||
# Check for Responses API events
|
||||
elif data.get('type', '').startswith('response.') or data.get('type', '') == 'error':
|
||||
response_data_type = data.get('type', '')
|
||||
response_data_is_delta = response_data_type.endswith('.delta')
|
||||
output, response_metadata = handle_responses_streaming_event(data, output)
|
||||
|
|
@ -5173,6 +5176,20 @@ async def streaming_chat_response_handler(response, ctx):
|
|||
response_metadata['usage'] = usage
|
||||
|
||||
if response_metadata.get('error'):
|
||||
log.error(
|
||||
'Provider returned error (streaming): %s', response_metadata['error']
|
||||
)
|
||||
if save_to_chat:
|
||||
try:
|
||||
await Chats.upsert_message_to_chat_by_id_and_message_id(
|
||||
metadata['chat_id'],
|
||||
metadata['message_id'],
|
||||
{
|
||||
'error': {'content': response_metadata['error']},
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
await event_emitter(
|
||||
{
|
||||
'type': 'chat:completion',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue