From 06820e701c119b2f9d9fcec0a3a33d7511cf2f55 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 6 Apr 2025 19:14:24 -0700 Subject: [PATCH] refac: citations modal --- .../components/chat/Messages/CitationsModal.svelte | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/components/chat/Messages/CitationsModal.svelte b/src/lib/components/chat/Messages/CitationsModal.svelte index cb740ce69..c77a8193b 100644 --- a/src/lib/components/chat/Messages/CitationsModal.svelte +++ b/src/lib/components/chat/Messages/CitationsModal.svelte @@ -14,6 +14,7 @@ let mergedDocuments = []; function calculatePercentage(distance: number) { + if (typeof distance !== 'number') return null; if (distance < 0) return 0; if (distance > 1) return 100; return Math.round(distance * 10000) / 100; @@ -122,11 +123,14 @@
{#if showPercentage} {@const percentage = calculatePercentage(document.distance)} - - {percentage.toFixed(2)}% - + + {#if typeof percentage === 'number'} + + {percentage.toFixed(2)}% + + {/if} ({(document?.distance ?? 0).toFixed(4)})