From 299b3d72cfe7818a842cc6f4ae33e42648577a1e Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 24 Sep 2024 14:02:41 +0200 Subject: [PATCH] fix: rate responses --- src/lib/components/chat/Messages/RateComment.svelte | 11 ++++++----- .../components/chat/Messages/ResponseMessage.svelte | 12 +++++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib/components/chat/Messages/RateComment.svelte b/src/lib/components/chat/Messages/RateComment.svelte index 73261ce66..6bb8cfee2 100644 --- a/src/lib/components/chat/Messages/RateComment.svelte +++ b/src/lib/components/chat/Messages/RateComment.svelte @@ -7,9 +7,8 @@ const dispatch = createEventDispatcher(); - export let messageId = null; - export let show = false; export let message; + export let show = false; let LIKE_REASONS = []; let DISLIKE_REASONS = []; @@ -54,8 +53,10 @@ const submitHandler = () => { console.log('submitHandler'); - message.annotation.reason = selectedReason; - message.annotation.comment = comment; + if (!selectedReason) { + toast.error($i18n.t('Please select a reason')); + return; + } dispatch('submit', { reason: selectedReason, @@ -69,7 +70,7 @@
{$i18n.t('Tell us more:')}
diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 6f1927b6f..ff1983cbd 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -1035,11 +1035,17 @@ {#if message.done && showRateComment} { - dispatch('update'); + dispatch('save', { + ...message, + annotation: { + ...message.annotation, + comment: e.detail.comment, + reason: e.detail.reason + } + }); (model?.actions ?? []) .filter((action) => action?.__webui__ ?? false) .forEach((action) => {