mirror of
https://github.com/open-webui/open-webui
synced 2025-02-01 15:24:25 +00:00
enh: check for reasoning tags
This commit is contained in:
parent
5420c165c6
commit
08ad4ee018
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user