add prompt, response, and comment to feedback modal

This commit is contained in:
ayana 2025-06-24 22:39:38 -07:00
parent 610680ac14
commit 6a8d870b8e
2 changed files with 50 additions and 2 deletions

View File

@ -12,6 +12,24 @@
show = false;
onClose();
};
$: prompt = (() => {
const messages = selectedFeedback?.snapshot?.chat?.chat?.history?.messages;
const messageId = selectedFeedback?.meta?.message_id;
if (!messages || !messageId) return '';
const assistantMsg = messages[messageId];
if (!assistantMsg) return '';
const userMsg = assistantMsg.parentId ? messages[assistantMsg.parentId] : null;
return userMsg?.content ?? '';
})();
$: response = (() => {
const messages = selectedFeedback?.snapshot?.chat?.chat?.history?.messages;
const messageId = selectedFeedback?.meta?.message_id;
if (!messages || !messageId) return '';
const assistantMsg = messages[messageId];
return assistantMsg?.content ?? '';
})();
</script>
<Modal size="sm" bind:show>
@ -65,6 +83,30 @@
<span>{selectedFeedback?.data?.reason || '-'}</span>
</div>
</div>
<div class="flex flex-col w-full mb-2">
<div class=" mb-1 text-xs text-gray-500">{$i18n.t('Comment')}</div>
<div class="flex-1 text-xs">
<span>{selectedFeedback?.data?.comment || '-'}</span>
</div>
</div>
<div class="flex flex-col w-full mb-2">
<div class="mb-1 text-xs text-gray-500">{$i18n.t('Prompt')}</div>
<div
class="flex-1 text-xs whitespace-pre-line break-words bg-gray-50 dark:bg-gray-900 rounded px-2 py-1"
>
<span>{prompt || '-'}</span>
</div>
</div>
<div class="flex flex-col w-full mb-2">
<div class="mb-1 text-xs text-gray-500">{$i18n.t('Response')}</div>
<div
class="flex-1 text-xs whitespace-pre-line break-words bg-gray-50 dark:bg-gray-900 rounded px-2 py-1"
>
<span>{response || '-'}</span>
</div>
</div>
<div class="flex justify-end pt-2">
<button

View File

@ -97,9 +97,15 @@
let showFeedbackModal = false;
let selectedFeedback = null;
const openFeedbackModal = (feedback) => {
const openFeedbackModal = async (feedback) => {
const all = await exportAllFeedbacks(localStorage.token).catch((err) => {
toast.error(err);
return null;
});
const full = all.find((f) => f.id === feedback.id);
showFeedbackModal = true;
selectedFeedback = feedback;
selectedFeedback = full || feedback;
};
const closeFeedbackModal = () => {