From 1b2f80c85b0172dc89edb412e7e5a4096af05a66 Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Thu, 23 Mar 2023 01:25:32 +0800 Subject: [PATCH] fix: ShareGPT bug --- .../ChatContent/Message/MessageContent.tsx | 2 +- src/components/ShareGPT/ShareGPT.tsx | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/Chat/ChatContent/Message/MessageContent.tsx b/src/components/Chat/ChatContent/Message/MessageContent.tsx index 4e1b341..a6f7e7d 100644 --- a/src/components/Chat/ChatContent/Message/MessageContent.tsx +++ b/src/components/Chat/ChatContent/Message/MessageContent.tsx @@ -128,7 +128,7 @@ const ContentView = React.memo( return ( <> -
+
{ const chats = useStore.getState().chats; const currentChatIndex = useStore.getState().currentChatIndex; if (chats) { - const items: ShareGPTSubmitBodyInterface['items'] = chats[ - currentChatIndex - ].messages.map((message) => ({ - from: 'gpt', - value: `

${t(message.role)}

${message.content}`, - })); try { + const items: ShareGPTSubmitBodyInterface['items'] = []; + const messages = document.querySelectorAll('.share-gpt-message'); + + messages.forEach((message, index) => { + items.push({ + from: 'gpt', + value: `

${t( + chats[currentChatIndex].messages[index].role + )}

${message.innerHTML}`, + }); + }); + await submitShareGPT({ avatarUrl: '', items,