diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index bf9432c92..8c444588b 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -23,13 +23,13 @@ revertSanitizedResponseContent, sanitizeResponseContent } from '$lib/utils'; + import { WEBUI_BASE_URL } from '$lib/constants'; import Name from './Name.svelte'; import ProfileImage from './ProfileImage.svelte'; import Skeleton from './Skeleton.svelte'; import CodeBlock from './CodeBlock.svelte'; import Image from '$lib/components/common/Image.svelte'; - import { WEBUI_BASE_URL } from '$lib/constants'; import Tooltip from '$lib/components/common/Tooltip.svelte'; import RateComment from './RateComment.svelte'; import CitationsModal from '$lib/components/chat/Messages/CitationsModal.svelte'; @@ -366,6 +366,7 @@ {/each} {/if} +
@@ -446,466 +447,474 @@ {/each} {/if} + + {#if message.citations} +
+
+ {#each message.citations.reduce((acc, citation) => { + citation.document.forEach((document, index) => { + const metadata = citation.metadata?.[index]; + const id = metadata?.source ?? 'N/A'; + + const existingSource = acc.find((item) => item.id === id); + + if (existingSource) { + existingSource.document.push(document); + existingSource.metadata.push(metadata); + } else { + acc.push( { id: id, source: citation?.source, document: [document], metadata: metadata ? [metadata] : [] } ); + } + }); + return acc; + }, []) as citation, idx} +
+
+ [{idx + 1}] +
+ + +
+ {/each} +
+ {/if} + + {#if message.done} +
+ {#if siblings.length > 1} +
+ + +
+ {siblings.indexOf(message.id) + 1} / {siblings.length} +
+ + +
+ {/if} + + {#if !readOnly} + + + + {/if} + + + + + + {#if !readOnly} + + + + + + + + {/if} + + + + + + {#if $config.images && !readOnly} + + + + {/if} + + {#if message.info} + + + + {/if} + + {#if isLastMessage && !readOnly} + + + + + + + + {/if} +
+ {/if} + + {#if showRateComment} + { + updateChatMessages(); + }} + /> + {/if}
{/if} - - {#if message.citations} -
-
- {#each message.citations.reduce((acc, citation) => { - citation.document.forEach((document, index) => { - const metadata = citation.metadata?.[index]; - const id = metadata?.source ?? 'N/A'; - - const existingSource = acc.find((item) => item.id === id); - - if (existingSource) { - existingSource.document.push(document); - existingSource.metadata.push(metadata); - } else { - acc.push( { id: id, source: citation?.source, document: [document], metadata: metadata ? [metadata] : [] } ); - } - }); - return acc; - }, []) as citation, idx} -
-
- [{idx + 1}] -
- - -
- {/each} -
- {/if} - - {#if message.done} -
- {#if siblings.length > 1} -
- - -
- {siblings.indexOf(message.id) + 1} / {siblings.length} -
- - -
- {/if} - - {#if !readOnly} - - - - {/if} - - - - - - {#if !readOnly} - - - - - - - - {/if} - - - - - - {#if $config.images && !readOnly} - - - - {/if} - - {#if message.info} - - - - {/if} - - {#if isLastMessage && !readOnly} - - - - - - - - {/if} -
- {/if} - - {#if showRateComment} - { - updateChatMessages(); - }} - /> - {/if} {/if}