-
- {idx + 1}
+
{$i18n.t('References from')}
+ {#each _citations.slice(0, 2) as citation, idx}
+
+
+
+ {#if idx === 0}
+
,
+ {/if}
+ {/each}
+
{$i18n.t('and')}
+
+ {_citations.length - 2}
-
- {citation.source.name}
+ {$i18n.t('more')}
+ {#if isCollapsibleOpen}
+
+ {:else}
+
+ {/if}
+
+
+
+ {#each _citations as citation, idx}
+
+
+
+ {/each}
-
-
- {/each}
+
+
+ {/if}
{/if}
diff --git a/src/lib/components/chat/Messages/CitationsModal.svelte b/src/lib/components/chat/Messages/CitationsModal.svelte
index 923fdea54..d2510d924 100644
--- a/src/lib/components/chat/Messages/CitationsModal.svelte
+++ b/src/lib/components/chat/Messages/CitationsModal.svelte
@@ -2,6 +2,7 @@
import { getContext, onMount, tick } from 'svelte';
import Modal from '$lib/components/common/Modal.svelte';
import Tooltip from '$lib/components/common/Tooltip.svelte';
+
const i18n = getContext('i18n');
export let show = false;
@@ -9,14 +10,32 @@
let mergedDocuments = [];
+ function calculatePercentage(distance) {
+ return Math.max(0, Math.min(100, (1 - distance / 2) * 100));
+ }
+
+ function getRelevanceColor(percentage) {
+ if (percentage >= 80)
+ return 'bg-green-200 dark:bg-green-800 text-green-800 dark:text-green-200';
+ if (percentage >= 60)
+ return 'bg-yellow-200 dark:bg-yellow-800 text-yellow-800 dark:text-yellow-200';
+ if (percentage >= 40)
+ return 'bg-orange-200 dark:bg-orange-800 text-orange-800 dark:text-orange-200';
+ return 'bg-red-200 dark:bg-red-800 text-red-800 dark:text-red-200';
+ }
+
$: if (citation) {
mergedDocuments = citation.document?.map((c, i) => {
return {
source: citation.source,
document: c,
- metadata: citation.metadata?.[i]
+ metadata: citation.metadata?.[i],
+ distance: citation.distances?.[i]
};
});
+ if (mergedDocuments.every((doc) => doc.distance !== undefined)) {
+ mergedDocuments.sort((a, b) => (a.distance ?? Infinity) - (b.distance ?? Infinity));
+ }
}
@@ -61,9 +80,9 @@
placement="left"
tippyOptions={{ duration: [500, 0], animation: 'perspective' }}
>
-
+
{document?.metadata?.name ?? document.source.name}
- {document?.metadata?.page
- ? `(${$i18n.t('page')} ${document.metadata.page + 1})`
- : ''}
+ {#if document?.metadata?.page}
+
+ ({$i18n.t('page')}
+ {document.metadata.page + 1})
+
+ {/if}
+ {#if document.distance !== undefined}
+
+ {$i18n.t('Relevance')}
+
+ {@const percentage = calculatePercentage(document.distance)}
+
+
+ {percentage.toFixed(0)}%
+
+ ({document.distance.toFixed(4)})
+
+ {/if}
{:else}
{$i18n.t('No source available')}
diff --git a/src/lib/i18n/locales/de-DE/translation.json b/src/lib/i18n/locales/de-DE/translation.json
index c1ccdae6d..7640a17a6 100644
--- a/src/lib/i18n/locales/de-DE/translation.json
+++ b/src/lib/i18n/locales/de-DE/translation.json
@@ -443,6 +443,7 @@
"Modelfile Content": "Modelfile-Inhalt",
"Models": "Modelle",
"More": "Mehr",
+ "more": "mehr",
"Move to Top": "",
"Name": "Name",
"Name Tag": "Namens-Tag",
@@ -784,5 +785,6 @@
"Your account status is currently pending activation.": "Ihr Kontostatus ist derzeit ausstehend und wartet auf Aktivierung.",
"Your entire contribution will go directly to the plugin developer; Open WebUI does not take any percentage. However, the chosen funding platform might have its own fees.": "",
"Youtube": "YouTube",
- "Youtube Loader Settings": "YouTube-Ladeeinstellungen"
+ "Youtube Loader Settings": "YouTube-Ladeeinstellungen",
+ "References from": "Referenzen aus"
}