From ad0b599940f36d3f4282e27284afffaddc6edc4b Mon Sep 17 00:00:00 2001 From: clang88 <71783092+clang88@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:35:08 +0100 Subject: [PATCH 1/2] Update calculatePercentage CitationsModal.svelte Fixes #6904 : Percentage score is high when low relevance and vice-versa. --- src/lib/components/chat/Messages/CitationsModal.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/Messages/CitationsModal.svelte b/src/lib/components/chat/Messages/CitationsModal.svelte index 61f274ffe..a2bca2ded 100644 --- a/src/lib/components/chat/Messages/CitationsModal.svelte +++ b/src/lib/components/chat/Messages/CitationsModal.svelte @@ -13,9 +13,9 @@ let mergedDocuments = []; function calculatePercentage(distance: number) { - if (distance < 0) return 100; - if (distance > 1) return 0; - return Math.round((1 - distance) * 10000) / 100; + if (distance < 0) return 0; + if (distance > 1) return 100; + return Math.round((distance * 10000) / 100; } function getRelevanceColor(percentage: number) { From 67cb3455ad7283acb9b4ad3afeae571346c27a1d Mon Sep 17 00:00:00 2001 From: clang88 <71783092+clang88@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:54:39 +0100 Subject: [PATCH 2/2] Update CitationsModal.svelte --- src/lib/components/chat/Messages/CitationsModal.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/chat/Messages/CitationsModal.svelte b/src/lib/components/chat/Messages/CitationsModal.svelte index a2bca2ded..88d6c7f6e 100644 --- a/src/lib/components/chat/Messages/CitationsModal.svelte +++ b/src/lib/components/chat/Messages/CitationsModal.svelte @@ -15,7 +15,7 @@ function calculatePercentage(distance: number) { if (distance < 0) return 0; if (distance > 1) return 100; - return Math.round((distance * 10000) / 100; + return Math.round(distance * 10000) / 100; } function getRelevanceColor(percentage: number) {