🐛 fix(Playground): Prevent markdown error from <think> tags in reasoning display

- Modified the `renderCustomChatContent` function to strip `<think>` and `</think>` tags from `finalExtractedThinkingContent` before passing it to the `MarkdownRender` component. This resolves potential parsing errors caused by unclosed or malformed tags.
- Added a conditional check to ensure that the thinking process block is only rendered if `finalExtractedThinkingContent` has actual content and the section is expanded, improving rendering stability.
This commit is contained in:
Apple\Apple
2025-05-29 11:25:26 +08:00
parent 2dcd6fa2b9
commit 31ece25252

View File

@@ -1161,11 +1161,11 @@ const Playground = () => {
className={`transition-all duration-500 ease-out ${message.isReasoningExpanded ? 'max-h-96 opacity-100' : 'max-h-0 opacity-0'
} overflow-hidden`}
>
{message.isReasoningExpanded && (
{message.isReasoningExpanded && finalExtractedThinkingContent && (
<div className="p-5 pt-4">
<div className="bg-white/70 backdrop-blur-sm rounded-xl p-4 shadow-inner overflow-x-auto max-h-50 overflow-y-auto">
<div className="prose prose-sm prose-purple max-w-none">
<MarkdownRender raw={finalExtractedThinkingContent} />
<MarkdownRender raw={finalExtractedThinkingContent.replace(/<\/?think>/g, '')} />
</div>
</div>
</div>