mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
fix: fillter exception handling
This commit is contained in:
parent
4b97884fce
commit
f56889c5c7
3 changed files with 23 additions and 9 deletions
|
|
@ -1519,7 +1519,7 @@ async def chat_completion(
|
|||
try:
|
||||
event_emitter = get_event_emitter(metadata)
|
||||
await event_emitter(
|
||||
{"type": "task-cancelled"},
|
||||
{"type": "chat:tasks:cancel"},
|
||||
)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
|
@ -1535,14 +1535,21 @@ async def chat_completion(
|
|||
"error": {"content": str(e)},
|
||||
},
|
||||
)
|
||||
|
||||
event_emitter = get_event_emitter(metadata)
|
||||
await event_emitter(
|
||||
{
|
||||
"type": "chat:message:error",
|
||||
"data": {"error": {"content": str(e)}},
|
||||
}
|
||||
)
|
||||
await event_emitter(
|
||||
{"type": "chat:tasks:cancel"},
|
||||
)
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=str(e),
|
||||
)
|
||||
|
||||
if (
|
||||
metadata.get("session_id")
|
||||
and metadata.get("chat_id")
|
||||
|
|
|
|||
|
|
@ -885,7 +885,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
extra_params=extra_params,
|
||||
)
|
||||
except Exception as e:
|
||||
raise Exception(f"Error: {e}")
|
||||
raise Exception(f"{e}")
|
||||
|
||||
features = form_data.pop("features", None)
|
||||
if features:
|
||||
|
|
@ -1316,7 +1316,7 @@ async def process_chat_response(
|
|||
{
|
||||
"type": "chat:message:error",
|
||||
"data": {"error": {"content": error}},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
if "selected_model_id" in response_data:
|
||||
|
|
@ -2624,7 +2624,7 @@ async def process_chat_response(
|
|||
await background_tasks_handler()
|
||||
except asyncio.CancelledError:
|
||||
log.warning("Task was cancelled!")
|
||||
await event_emitter({"type": "task-cancelled"})
|
||||
await event_emitter({"type": "chat:tasks:cancel"})
|
||||
|
||||
if not ENABLE_REALTIME_CHAT_SAVE:
|
||||
# Save message in the database
|
||||
|
|
|
|||
|
|
@ -318,6 +318,13 @@
|
|||
}
|
||||
} else if (type === 'chat:completion') {
|
||||
chatCompletionEventHandler(data, message, event.chat_id);
|
||||
} else if (type === 'chat:tasks:cancel') {
|
||||
taskIds = null;
|
||||
const responseMessage = history.messages[history.currentId];
|
||||
// Set all response messages to done
|
||||
for (const messageId of history.messages[responseMessage.parentId].childrenIds) {
|
||||
history.messages[messageId].done = true;
|
||||
}
|
||||
} else if (type === 'chat:message:delta' || type === 'message') {
|
||||
message.content += data.content;
|
||||
} else if (type === 'chat:message' || type === 'replace') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue