fixed duplicated message
This commit is contained in:
parent
bb5dae166f
commit
4ca064ebdc
3 changed files with 374 additions and 358 deletions
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function codeBlock() {
|
||||||
|
// a html custom element for code blocks in markdown texts, it will allow to download the code as a file or copy it to the clipboard
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>Code Block</h1>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -65,6 +65,14 @@ export default function ChatMessage({ chat }: { chat: ChatMessageType }) {
|
||||||
remarkPlugins={[remarkGfm, remarkMath]}
|
remarkPlugins={[remarkGfm, remarkMath]}
|
||||||
rehypePlugins={[rehypeMathjax]}
|
rehypePlugins={[rehypeMathjax]}
|
||||||
className="markdown prose"
|
className="markdown prose"
|
||||||
|
// components={{
|
||||||
|
// code: (props) => (
|
||||||
|
// <code
|
||||||
|
// className="bg-pink-600 dark:bg-gray-700 rounded-md p-1"
|
||||||
|
// {...props}
|
||||||
|
// />
|
||||||
|
// ),
|
||||||
|
// }}
|
||||||
>
|
>
|
||||||
{message}
|
{message}
|
||||||
</ReactMarkdown>
|
</ReactMarkdown>
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,13 @@ export default function ChatModal({
|
||||||
setChatHistory((old) => {
|
setChatHistory((old) => {
|
||||||
let newChat = [...old];
|
let newChat = [...old];
|
||||||
if (str) {
|
if (str) {
|
||||||
if (end && !newChat[newChat.length - 1].message) {
|
if (end) {
|
||||||
newChat[newChat.length - 1].message = str;
|
newChat[newChat.length - 1].message = str;
|
||||||
}
|
} else {
|
||||||
newChat[newChat.length - 1].message =
|
newChat[newChat.length - 1].message =
|
||||||
newChat[newChat.length - 1].message + str;
|
newChat[newChat.length - 1].message + str;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (thought) {
|
if (thought) {
|
||||||
newChat[newChat.length - 1].thought = thought;
|
newChat[newChat.length - 1].thought = thought;
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +138,6 @@ export default function ChatModal({
|
||||||
thought: data.intermediate_steps,
|
thought: data.intermediate_steps,
|
||||||
end: true,
|
end: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
setLockChat(false);
|
setLockChat(false);
|
||||||
isStream = false;
|
isStream = false;
|
||||||
|
|
@ -346,7 +346,7 @@ export default function ChatModal({
|
||||||
<div className="relative w-full">
|
<div className="relative w-full">
|
||||||
<button
|
<button
|
||||||
onClick={() => clearChat()}
|
onClick={() => clearChat()}
|
||||||
className="absolute top-2 right-2 hover:text-red-500"
|
className="absolute top-2 right-2 hover:text-red-500 z-30"
|
||||||
>
|
>
|
||||||
<FaEraser className="w-4 h-4" />
|
<FaEraser className="w-4 h-4" />
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue