mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
refac: citations modal
This commit is contained in:
parent
2be08f27ea
commit
06820e701c
@ -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 @@
|
||||
<div class="text-sm my-1 dark:text-gray-400 flex items-center gap-2 w-fit">
|
||||
{#if showPercentage}
|
||||
{@const percentage = calculatePercentage(document.distance)}
|
||||
<span
|
||||
class={`px-1 rounded-sm font-medium ${getRelevanceColor(percentage)}`}
|
||||
>
|
||||
{percentage.toFixed(2)}%
|
||||
</span>
|
||||
|
||||
{#if typeof percentage === 'number'}
|
||||
<span
|
||||
class={`px-1 rounded-sm font-medium ${getRelevanceColor(percentage)}`}
|
||||
>
|
||||
{percentage.toFixed(2)}%
|
||||
</span>
|
||||
{/if}
|
||||
<span class="text-gray-500 dark:text-gray-500">
|
||||
({(document?.distance ?? 0).toFixed(4)})
|
||||
</span>
|
||||
|
Loading…
Reference in New Issue
Block a user