From 08ad4ee018dfcc97d3c5efa2f08305a035d4c5e1 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 29 Jan 2025 14:59:23 -0800 Subject: [PATCH] enh: check for reasoning tags --- backend/open_webui/routers/tasks.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/tasks.py b/backend/open_webui/routers/tasks.py index 2dc58b4a5..df86b4c10 100644 --- a/backend/open_webui/routers/tasks.py +++ b/backend/open_webui/routers/tasks.py @@ -4,6 +4,7 @@ from fastapi.responses import JSONResponse, RedirectResponse from pydantic import BaseModel from typing import Optional import logging +import re from open_webui.utils.chat import generate_chat_completion from open_webui.utils.task import ( @@ -161,9 +162,22 @@ async def generate_title( else: template = DEFAULT_TITLE_GENERATION_PROMPT_TEMPLATE + messages = form_data["messages"] + + # Remove reasoning details from the messages + for message in messages: + message["content"] = re.sub( + r"]*>.*?<\/details>", + "", + message["content"], + flags=re.S, + ).strip() + + print(messages) + content = title_generation_template( template, - form_data["messages"], + messages, { "name": user.name, "location": user.info.get("location") if user.info else None,