mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 11:26:52 +08:00
feat: improve think content display (#13431)
This commit is contained in:
@@ -22,6 +22,7 @@ import AudioGallery from '@/app/components/base/audio-gallery'
|
||||
import SVGRenderer from '@/app/components/base/svg-gallery'
|
||||
import MarkdownButton from '@/app/components/base/markdown-blocks/button'
|
||||
import MarkdownForm from '@/app/components/base/markdown-blocks/form'
|
||||
import ThinkBlock from '@/app/components/base/markdown-blocks/think-block'
|
||||
|
||||
// Available language https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_HLJS.MD
|
||||
const capitalizationLanguageNameMap: Record<string, string> = {
|
||||
@@ -72,10 +73,8 @@ const preprocessThinkTag = (content: string) => {
|
||||
return content
|
||||
|
||||
return flow([
|
||||
(str: string) => str.replace('<think>\n', '<details open><summary class="text-gray-500 font-bold">Thinking</summary><div class="text-gray-500 p-3 ml-2 bg-gray-50 border-l border-gray-300">\n'),
|
||||
(str: string) => str.includes('\n</think>')
|
||||
? str.replace('\n</think>', '\n</div></details>')
|
||||
: `${str}\n</div></details>`,
|
||||
(str: string) => str.replace('<think>\n', '<details>\n'),
|
||||
(str: string) => str.replace('\n</think>', '\n[ENDTHINKFLAG]</details>'),
|
||||
])(content)
|
||||
}
|
||||
|
||||
@@ -281,6 +280,7 @@ export function Markdown(props: { content: string; className?: string }) {
|
||||
button: MarkdownButton,
|
||||
form: MarkdownForm,
|
||||
script: ScriptBlock,
|
||||
details: ThinkBlock,
|
||||
}}
|
||||
linkTarget='_blank'
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user