mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 04:45:19 +00:00
refac/fix: reasoning content tag parsing
This commit is contained in:
parent
d14329b285
commit
024f78d3e0
2 changed files with 9 additions and 8 deletions
|
|
@ -1543,9 +1543,7 @@ async def process_chat_response(
|
|||
if not metadata.get("chat_id", "").startswith(
|
||||
"local:"
|
||||
): # Only update titles and tags for non-temp chats
|
||||
if (
|
||||
TASKS.TITLE_GENERATION in tasks
|
||||
):
|
||||
if TASKS.TITLE_GENERATION in tasks:
|
||||
user_message = get_last_user_message(messages)
|
||||
if user_message and len(user_message) > 100:
|
||||
user_message = user_message[:100] + "..."
|
||||
|
|
@ -1938,9 +1936,11 @@ async def process_chat_response(
|
|||
content = f"{content}{tool_calls_display_content}"
|
||||
|
||||
elif block["type"] == "reasoning":
|
||||
reasoning_display_content = "\n".join(
|
||||
(f"> {line}" if not line.startswith(">") else line)
|
||||
for line in block["content"].splitlines()
|
||||
reasoning_display_content = html.escape(
|
||||
"\n".join(
|
||||
(f"> {line}" if not line.startswith(">") else line)
|
||||
for line in block["content"].splitlines()
|
||||
)
|
||||
)
|
||||
|
||||
reasoning_duration = block.get("duration", None)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { decode } from 'html-entities';
|
||||
import DOMPurify from 'dompurify';
|
||||
import { onMount, getContext } from 'svelte';
|
||||
const i18n = getContext('i18n');
|
||||
|
|
@ -10,6 +11,7 @@
|
|||
import { unescapeHtml } from '$lib/utils';
|
||||
|
||||
import { WEBUI_BASE_URL } from '$lib/constants';
|
||||
import { settings } from '$lib/stores';
|
||||
|
||||
import CodeBlock from '$lib/components/chat/Messages/CodeBlock.svelte';
|
||||
import MarkdownInlineTokens from '$lib/components/chat/Messages/Markdown/MarkdownInlineTokens.svelte';
|
||||
|
|
@ -20,7 +22,6 @@
|
|||
import Download from '$lib/components/icons/Download.svelte';
|
||||
|
||||
import Source from './Source.svelte';
|
||||
import { settings } from '$lib/stores';
|
||||
import HtmlToken from './HTMLToken.svelte';
|
||||
|
||||
export let id: string;
|
||||
|
|
@ -304,7 +305,7 @@
|
|||
<div class=" mb-1.5" slot="content">
|
||||
<svelte:self
|
||||
id={`${id}-${tokenIdx}-d`}
|
||||
tokens={marked.lexer(token.text)}
|
||||
tokens={marked.lexer(decode(token.text))}
|
||||
attributes={token?.attributes}
|
||||
{done}
|
||||
{editCodeBlock}
|
||||
|
|
|
|||
Loading…
Reference in a new issue