fix: ShareGPT bug

This commit is contained in:
Jing Hua 2023-03-23 01:25:32 +08:00
parent f797f6984c
commit 1b2f80c85b
2 changed files with 13 additions and 7 deletions

View file

@ -128,7 +128,7 @@ const ContentView = React.memo(
return ( return (
<> <>
<div className='markdown prose w-full break-words dark:prose-invert dark'> <div className='markdown prose w-full break-words dark:prose-invert dark share-gpt-message'>
<ReactMarkdown <ReactMarkdown
remarkPlugins={[ remarkPlugins={[
remarkGfm, remarkGfm,

View file

@ -14,13 +14,19 @@ const ShareGPT = React.memo(() => {
const chats = useStore.getState().chats; const chats = useStore.getState().chats;
const currentChatIndex = useStore.getState().currentChatIndex; const currentChatIndex = useStore.getState().currentChatIndex;
if (chats) { if (chats) {
const items: ShareGPTSubmitBodyInterface['items'] = chats[
currentChatIndex
].messages.map((message) => ({
from: 'gpt',
value: `<p><b>${t(message.role)}</b></p>${message.content}`,
}));
try { try {
const items: ShareGPTSubmitBodyInterface['items'] = [];
const messages = document.querySelectorAll('.share-gpt-message');
messages.forEach((message, index) => {
items.push({
from: 'gpt',
value: `<p><b>${t(
chats[currentChatIndex].messages[index].role
)}</b></p>${message.innerHTML}`,
});
});
await submitShareGPT({ await submitShareGPT({
avatarUrl: '', avatarUrl: '',
items, items,