This commit is contained in:
parent
e6164160ef
commit
a6e77c12fe
|
|
@ -41,17 +41,26 @@ interface MessageProps {
|
|||
const MessageContent: React.FC<{ content: string }> = ({ content }) => {
|
||||
const [showThink, setShowThink] = useState(false)
|
||||
|
||||
const thinkMatch = content.match(/<think>([\s\S]*?)<\/think>/i)
|
||||
const thinkContent = thinkMatch?.[1]?.trim() || ""
|
||||
const visibleContent = thinkMatch
|
||||
? content.replace(thinkMatch[0], "").trim()
|
||||
: content.trim()
|
||||
let thinkContent = ""
|
||||
let visibleContent = content.trim()
|
||||
|
||||
const fullMatch = content.match(/<think>([\s\S]*?)<\/think>/i)
|
||||
if (fullMatch) {
|
||||
thinkContent = fullMatch[1].trim()
|
||||
visibleContent = content.replace(fullMatch[0], "").trim()
|
||||
} else {
|
||||
const endOnlyMatch = content.match(/([\s\S]*?)<\/think>/i)
|
||||
if (endOnlyMatch) {
|
||||
thinkContent = endOnlyMatch[1].trim()
|
||||
visibleContent = content.replace(endOnlyMatch[0], "").trim()
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<MessageMarkdown content={visibleContent} />
|
||||
|
||||
{thinkMatch && thinkContent && (
|
||||
{thinkContent && (
|
||||
<div className="mt-2 text-sm text-muted-foreground">
|
||||
<button
|
||||
className="text-blue-500 hover:underline"
|
||||
|
|
@ -71,6 +80,7 @@ const MessageContent: React.FC<{ content: string }> = ({ content }) => {
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
export const Message: FC<MessageProps> = ({
|
||||
message,
|
||||
fileItems,
|
||||
|
|
|
|||
Loading…
Reference in New Issue