diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index 4cd97ca80..892777662 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -107,12 +107,8 @@ await sendPrompt(userPrompt, userMessageId, chatId); }; - const confirmEditResponseMessage = async (messageId, content) => { - history.messages[messageId].originalContent = history.messages[messageId].content; - history.messages[messageId].content = content; - + const updateChatMessages = async () => { await tick(); - await updateChatById(localStorage.token, chatId, { messages: messages, history: history @@ -121,15 +117,20 @@ await chats.set(await getChatList(localStorage.token)); }; - const rateMessage = async (messageId, rating) => { - history.messages[messageId].rating = rating; - await tick(); - await updateChatById(localStorage.token, chatId, { - messages: messages, - history: history - }); + const confirmEditResponseMessage = async (messageId, content) => { + history.messages[messageId].originalContent = history.messages[messageId].content; + history.messages[messageId].content = content; - await chats.set(await getChatList(localStorage.token)); + await updateChatMessages(); + }; + + const rateMessage = async (messageId, rating) => { + history.messages[messageId].annotation = { + ...history.messages[messageId].annotation, + rating: rating + }; + + await updateChatMessages(); }; const showPreviousMessage = async (message) => { @@ -338,6 +339,7 @@ siblings={history.messages[message.parentId]?.childrenIds ?? []} isLastMessage={messageIdx + 1 === messages.length} {readOnly} + {updateChatMessages} {confirmEditResponseMessage} {showPreviousMessage} {showNextMessage} diff --git a/src/lib/components/chat/Messages/RateComment.svelte b/src/lib/components/chat/Messages/RateComment.svelte new file mode 100644 index 000000000..1ffd22aaf --- /dev/null +++ b/src/lib/components/chat/Messages/RateComment.svelte @@ -0,0 +1,117 @@ + + +
+
+
Tell us more:
+ + +
+ + {#if reasons.length > 0} +
+ {#each reasons as reason} + + {/each} +
+ {/if} + +
+