mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 05:55:52 +08:00
fix: frontend for <think> tags conflicting with original <details> tags (#14039)
This commit is contained in:
parent
3f34b8b0d1
commit
d96c368660
@ -68,6 +68,9 @@ export const ThinkBlock = ({ children, ...props }: any) => {
|
|||||||
const displayContent = removeEndThink(children)
|
const displayContent = removeEndThink(children)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
if (!(props['data-think'] ?? false))
|
||||||
|
return (<details {...props}>{children}</details>)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<details {...(!isComplete && { open: true })} className="group">
|
<details {...(!isComplete && { open: true })} className="group">
|
||||||
<summary className="text-gray-500 font-bold list-none pl-2 flex items-center cursor-pointer select-none whitespace-nowrap">
|
<summary className="text-gray-500 font-bold list-none pl-2 flex items-center cursor-pointer select-none whitespace-nowrap">
|
||||||
|
@ -68,13 +68,9 @@ const preprocessLaTeX = (content: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const preprocessThinkTag = (content: string) => {
|
const preprocessThinkTag = (content: string) => {
|
||||||
if (!(content.trim().startsWith('<think>\n') || content.trim().startsWith('<details style=')))
|
|
||||||
return content
|
|
||||||
|
|
||||||
return flow([
|
return flow([
|
||||||
(str: string) => str.replaceAll('<think>\n', '<details>\n'),
|
(str: string) => str.replace('<think>\n', '<details data-think=true>\n'),
|
||||||
(str: string) => str.replaceAll('\n</think>', '\n[ENDTHINKFLAG]</details>'),
|
(str: string) => str.replace('\n</think>', '\n[ENDTHINKFLAG]</details>'),
|
||||||
(str: string) => str.replaceAll('\n</details>', '\n[ENDTHINKFLAG]</details>'),
|
|
||||||
])(content)
|
])(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user