Skip to content

Commit 6c64698

Browse files
authored
Merge pull request #116 from OpenAgentPlatform/think
feat: add style for <think>
2 parents 9243ebc + 7235498 commit 6c64698

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Diff for: src/styles/pages/_Chat.scss

+9-3
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,12 @@
535535
}
536536
}
537537
}
538-
538+
539539
pre {
540540
margin: 0;
541541
padding: 12px;
542542
overflow-x: auto;
543-
543+
544544
code {
545545
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
546546
font-size: 14px;
@@ -957,4 +957,10 @@
957957
margin: 0.5em 0;
958958
background: rgba(255, 77, 79, 0.1);
959959
border-radius: 6px;
960-
}
960+
}
961+
962+
.think {
963+
padding: 1em;
964+
margin: 0.5em 0;
965+
color: var(--text-weak);
966+
}

Diff for: src/views/Chat/Message.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ declare global {
2424
children: any
2525
name: string
2626
};
27+
"think": {
28+
children: any
29+
};
2730
}
2831
}
2932
}
@@ -138,7 +141,13 @@ const Message = ({ messageId, text, isSent, files, isError, isLoading, onRetry,
138141
inlineMathDouble: false
139142
}], remarkGfm]}
140143
rehypePlugins={[rehypeKatex, rehypeRaw]}
144+
remarkRehypeOptions={{
145+
allowDangerousHtml: true
146+
}}
141147
components={{
148+
"think"({ children }) {
149+
return <div className="think">{children}</div>
150+
},
142151
"tool-call"({children, name}) {
143152
let content = children
144153
if (typeof children !== "string") {
@@ -243,7 +252,7 @@ const Message = ({ messageId, text, isSent, files, isError, isLoading, onRetry,
243252
}
244253
}}
245254
>
246-
{_text.replaceAll("file://", "https://localfile")}
255+
{_text.replaceAll("file://", "https://localfile").replaceAll("</think>\n\n", "\n\n</think>\n\n")}
247256
</ReactMarkdown>
248257
)
249258
}, [content, text, isSent, isLoading])

0 commit comments

Comments
 (0)