From 4c490132ba77e78433d3b7b2474b69b07bf60eb8 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 6 May 2024 15:14:33 -0700 Subject: [PATCH] refac: styling --- backend/apps/rag/utils.py | 2 + .../chat/Messages/CitationsModal.svelte | 49 ++++++++++--------- .../chat/Messages/ResponseMessage.svelte | 2 + 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/backend/apps/rag/utils.py b/backend/apps/rag/utils.py index 8efa1a9f7..944abb219 100644 --- a/backend/apps/rag/utils.py +++ b/backend/apps/rag/utils.py @@ -320,6 +320,7 @@ def rag_messages( extracted_collections.extend(collection) context_string = "" + citations = [] for context in relevant_contexts: try: @@ -335,6 +336,7 @@ def rag_messages( ) except Exception as e: log.exception(e) + context_string = context_string.strip() ra_content = rag_template( diff --git a/src/lib/components/chat/Messages/CitationsModal.svelte b/src/lib/components/chat/Messages/CitationsModal.svelte index 1043577e8..8a030b7b8 100644 --- a/src/lib/components/chat/Messages/CitationsModal.svelte +++ b/src/lib/components/chat/Messages/CitationsModal.svelte @@ -23,7 +23,7 @@
-
+
{$i18n.t('Citation')}
@@ -45,29 +45,32 @@
-
- {#each mergedDocuments as document, documentIdx} -
-
- {$i18n.t('Source')} -
-
- {document.metadata?.source ?? $i18n.t('No source available')} -
-
-
-
- {$i18n.t('Content')} -
-
-						{document.document}
-					
-
- {#if documentIdx !== mergedDocuments.length - 1} -
- {/if} - {/each} +
+
+ {#each mergedDocuments as document, documentIdx} +
+
+ {$i18n.t('Source')} +
+
+ {document.metadata?.source ?? $i18n.t('No source available')} +
+
+
+
+ {$i18n.t('Content')} +
+
+							{document.document}
+						
+
+ + {#if documentIdx !== mergedDocuments.length - 1} +
+ {/if} + {/each} +
diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 033ebcf7a..b7a4f259c 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -141,6 +141,7 @@ const zipped = (citation?.document ?? []).map(function (document, index) { return [document, citation.metadata?.[index]]; }); + for (const [document, metadata] of zipped) { const source = metadata?.source ?? 'N/A'; if (source in flattenedCitations) { @@ -154,6 +155,7 @@ } } } + console.log(flattenedCitations); console.log(Object.keys(flattenedCitations)); }