From 31c176a485642d2bc860ff833a06f6db13127798 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 3 Feb 2025 16:18:07 -0800 Subject: [PATCH] refac --- backend/open_webui/utils/middleware.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 644ec9014..71e32c755 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -1107,9 +1107,15 @@ async def process_chat_response( reasoning_duration = block.get("duration", None) if reasoning_duration: - content = f'{content}
\nThought for {reasoning_duration} seconds\n{reasoning_display_content}\n
\n' + if raw: + content = f'{content}<{block["tag"]}>{block["content"]}\n' + else: + content = f'{content}
\nThought for {reasoning_duration} seconds\n{reasoning_display_content}\n
\n' else: - content = f'{content}
\nThinking…\n{reasoning_display_content}\n
\n' + if raw: + content = f'{content}<{block["tag"]}>{block["content"]}\n' + else: + content = f'{content}
\nThinking…\n{reasoning_display_content}\n
\n' elif block["type"] == "code_interpreter": attributes = block.get("attributes", {}) @@ -1124,7 +1130,10 @@ async def process_chat_response( else: content = f'{content}
\nAnalyzed\n```{lang}\n{block["content"]}\n```\n
\n' else: - content = f'{content}
\nAnalyzing...\n```{lang}\n{block["content"]}\n```\n
\n' + if raw: + content = f'{content}\n{block["content"]}\n\n' + else: + content = f'{content}
\nAnalyzing...\n```{lang}\n{block["content"]}\n```\n
\n' else: block_content = str(block["content"]).strip()