|
@@ -4,6 +4,7 @@ from fastapi.responses import JSONResponse, RedirectResponse
|
|
from pydantic import BaseModel
|
|
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from typing import Optional
|
|
import logging
|
|
import logging
|
|
|
|
+import re
|
|
|
|
|
|
from open_webui.utils.chat import generate_chat_completion
|
|
from open_webui.utils.chat import generate_chat_completion
|
|
from open_webui.utils.task import (
|
|
from open_webui.utils.task import (
|
|
@@ -161,9 +162,22 @@ async def generate_title(
|
|
else:
|
|
else:
|
|
template = DEFAULT_TITLE_GENERATION_PROMPT_TEMPLATE
|
|
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\s+type=\"reasoning\"[^>]*>.*?<\/details>",
|
|
|
|
+ "",
|
|
|
|
+ message["content"],
|
|
|
|
+ flags=re.S,
|
|
|
|
+ ).strip()
|
|
|
|
+
|
|
|
|
+ print(messages)
|
|
|
|
+
|
|
content = title_generation_template(
|
|
content = title_generation_template(
|
|
template,
|
|
template,
|
|
- form_data["messages"],
|
|
|
|
|
|
+ messages,
|
|
{
|
|
{
|
|
"name": user.name,
|
|
"name": user.name,
|
|
"location": user.info.get("location") if user.info else None,
|
|
"location": user.info.get("location") if user.info else None,
|