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