From 26d069080ae1decac243e43862a3ecc375b6dad5 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 16 Jun 2025 13:45:36 +0400 Subject: [PATCH] refac --- backend/open_webui/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index b9324efa4..8fa2cf42f 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1373,6 +1373,17 @@ async def chat_completion( request, response, form_data, user, metadata, model, events, tasks ) except Exception as e: + log.debug(f"Error in chat completion: {e}") + if metadata.get("chat_id") and metadata.get("message_id"): + # Update the chat message with the error + Chats.upsert_message_to_chat_by_id_and_message_id( + metadata["chat_id"], + metadata["message_id"], + { + "error": {"content": str(e)}, + }, + ) + raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, detail=str(e),