Explorar o código

Merge pull request #10268 from hurxxxx/feat/hide-citations-in-message

feat: citations disabled model to exclude source citations in messages
Timothy Jaeryang Baek hai 2 meses
pai
achega
c658781995

+ 5 - 0
src/lib/components/chat/Messages/ContentRenderer.svelte

@@ -120,6 +120,11 @@
 		sourceIds={(sources ?? []).reduce((acc, s) => {
 			let ids = [];
 			s.document.forEach((document, index) => {
+				if (model?.info?.meta?.capabilities?.citations == false) {
+					ids.push('N/A');
+					return ids;
+				}
+
 				const metadata = s.metadata?.[index];
 				const id = metadata?.source ?? 'N/A';
 

+ 12 - 10
src/lib/components/chat/Messages/Markdown/Source.svelte

@@ -35,13 +35,15 @@
 	$: attributes = extractAttributes(token.text);
 </script>
 
-<button
-	class="text-xs font-medium w-fit translate-y-[2px] px-2 py-0.5 dark:bg-white/5 dark:text-white/60 dark:hover:text-white bg-gray-50 text-black/60 hover:text-black transition rounded-lg"
-	on:click={() => {
-		onClick(attributes.data);
-	}}
->
-	<span class="line-clamp-1">
-		{attributes.title ? formattedTitle(attributes.title) : ''}
-	</span>
-</button>
+{#if attributes.title !== 'N/A'}
+	<button
+		class="text-xs font-medium w-fit translate-y-[2px] px-2 py-0.5 dark:bg-white/5 dark:text-white/60 dark:hover:text-white bg-gray-50 text-black/60 hover:text-black transition rounded-lg"
+		on:click={() => {
+			onClick(attributes.data);
+		}}
+	>
+		<span class="line-clamp-1">
+			{attributes.title ? formattedTitle(attributes.title) : ''}
+		</span>
+	</button>
+{/if}