mirror of
https://github.com/open-webui/open-webui
synced 2025-05-22 13:54:20 +00:00
refac
This commit is contained in:
parent
675403d26d
commit
eed2d735a1
@ -3,14 +3,9 @@
|
|||||||
|
|
||||||
export let citations = [];
|
export let citations = [];
|
||||||
|
|
||||||
let showCitationModal = false;
|
let _citations = [];
|
||||||
let selectedCitation = null;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<CitationsModal bind:show={showCitationModal} citation={selectedCitation} />
|
$: _citations = citations.reduce((acc, citation) => {
|
||||||
|
|
||||||
<div class="mt-1 mb-2 w-full flex gap-1 items-center flex-wrap">
|
|
||||||
{#each citations.reduce((acc, citation) => {
|
|
||||||
citation.document.forEach((document, index) => {
|
citation.document.forEach((document, index) => {
|
||||||
const metadata = citation.metadata?.[index];
|
const metadata = citation.metadata?.[index];
|
||||||
const id = metadata?.source ?? 'N/A';
|
const id = metadata?.source ?? 'N/A';
|
||||||
@ -31,26 +26,42 @@
|
|||||||
existingSource.document.push(document);
|
existingSource.document.push(document);
|
||||||
existingSource.metadata.push(metadata);
|
existingSource.metadata.push(metadata);
|
||||||
} else {
|
} else {
|
||||||
acc.push( { id: id, source: source, document: [document], metadata: metadata ? [metadata] : [] } );
|
acc.push({
|
||||||
|
id: id,
|
||||||
|
source: source,
|
||||||
|
document: [document],
|
||||||
|
metadata: metadata ? [metadata] : []
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return acc;
|
return acc;
|
||||||
}, []) as citation, idx}
|
}, []);
|
||||||
<div class="flex gap-1 text-xs font-semibold">
|
|
||||||
<button
|
let showCitationModal = false;
|
||||||
class="flex dark:text-gray-300 py-1 px-1 bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-xl"
|
let selectedCitation = null;
|
||||||
on:click={() => {
|
</script>
|
||||||
showCitationModal = true;
|
|
||||||
selectedCitation = citation;
|
<CitationsModal bind:show={showCitationModal} citation={selectedCitation} />
|
||||||
}}
|
|
||||||
>
|
{#if _citations.length > 0}
|
||||||
<div class="bg-white dark:bg-gray-700 rounded-full size-4">
|
<div class="mt-1 mb-2 w-full flex gap-1 items-center flex-wrap">
|
||||||
{idx + 1}
|
{#each _citations as citation, idx}
|
||||||
</div>
|
<div class="flex gap-1 text-xs font-semibold">
|
||||||
<div class="flex-1 mx-2 line-clamp-1">
|
<button
|
||||||
{citation.source.name}
|
class="flex dark:text-gray-300 py-1 px-1 bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-xl"
|
||||||
</div>
|
on:click={() => {
|
||||||
</button>
|
showCitationModal = true;
|
||||||
</div>
|
selectedCitation = citation;
|
||||||
{/each}
|
}}
|
||||||
</div>
|
>
|
||||||
|
<div class="bg-white dark:bg-gray-700 rounded-full size-4">
|
||||||
|
{idx + 1}
|
||||||
|
</div>
|
||||||
|
<div class="flex-1 mx-2 line-clamp-1">
|
||||||
|
{citation.source.name}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user