From e54879aeb17920afc3aa009d09e0e7546582d47a Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 19 Nov 2024 20:12:22 -0800 Subject: [PATCH] enh: detailed 1-10 rating --- .../chat/Messages/RateComment.svelte | 141 ++++++++++++------ .../chat/Messages/ResponseMessage.svelte | 15 +- 2 files changed, 97 insertions(+), 59 deletions(-) diff --git a/src/lib/components/chat/Messages/RateComment.svelte b/src/lib/components/chat/Messages/RateComment.svelte index 2cccf20d8..39ae17318 100644 --- a/src/lib/components/chat/Messages/RateComment.svelte +++ b/src/lib/components/chat/Messages/RateComment.svelte @@ -38,6 +38,7 @@ let selectedReason = null; let comment = ''; + let detailedRating = null; let selectedModel = null; $: if (message?.annotation?.rating === 1) { @@ -56,6 +57,7 @@ tags = (message?.annotation?.tags ?? []).map((tag) => ({ name: tag })); + detailedRating = message?.annotation?.details?.rating ?? null; }; onMount(() => { @@ -79,7 +81,10 @@ dispatch('save', { reason: selectedReason, comment: comment, - tags: tags.map((tag) => tag.name) + tags: tags.map((tag) => tag.name), + details: { + rating: detailedRating + } }); toast.success($i18n.t('Thanks for your feedback!')); @@ -100,7 +105,9 @@ id="message-feedback-{message.id}" >
-
{$i18n.t('Tell us more:')}
+
{$i18n.t('How would you rate this response?')}
+ +
- {#if reasons.length > 0} -
- {#each reasons as reason} - - {/each} +
+
+
+ + {#each Array.from({ length: 10 }).map((_, i) => i + 1) as rating} + + {/each} +
+ +
+
+ 1 - {$i18n.t('Awful')} +
+ +
+ 10 - {$i18n.t('Amazing')} +
+
- {/if} +
+ +
+ {#if reasons.length > 0} +
{$i18n.t('Why?')}
+ +
+ {#each reasons as reason} + + {/each} +
+ {/if} +