diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 2ab73292c..146e31cad 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -977,6 +977,20 @@ async def process_chat_response( if message: messages = get_message_list(message_map, message.get("id")) + # Remove reasoning details and files from the messages. + # as get_message_list creates a new list, it does not affect + # the original messages outside of this handler + for message in messages: + message["content"] = re.sub( + r"]*>.*?<\/details>", + "", + message["content"], + flags=re.S, + ).strip() + + if message.get('files'): + message['files'] = [] + if tasks and messages: if TASKS.TITLE_GENERATION in tasks: if tasks[TASKS.TITLE_GENERATION]: