From f49e1afaa642cba9fa82dd0c2921c80922dc3c42 Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Sun, 12 May 2024 20:44:46 +0800 Subject: [PATCH] feat: inject search result doc in the response, not the query this is to handle when we have multiple models selected or regenerate a response, it'll only add it to the model's response and not add dupes on the user message --- .../chat/Messages/ResponseMessage.svelte | 137 ++++++++++++------ src/routes/(app)/+page.svelte | 7 +- src/routes/(app)/c/[id]/+page.svelte | 7 +- 3 files changed, 96 insertions(+), 55 deletions(-) diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 48f2607f0..c7104be99 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -369,59 +369,102 @@ class="prose chat-{message.role} w-full max-w-full dark:prose-invert prose-headings:my-0 prose-p:m-0 prose-p:-mb-6 prose-pre:my-0 prose-table:my-0 prose-blockquote:my-0 prose-img:my-0 prose-ul:-my-4 prose-ol:-my-4 prose-li:-my-3 prose-ul:-mb-6 prose-ol:-mb-8 prose-ol:p-0 prose-li:-mb-4 whitespace-pre-line" >
- {#if message.progress} + {#if message.progress || message.files}
-
- +
+ {/if} + {#if message.files} + {#each message.files as file} +
+ {#if file.type === 'websearch'} + + {/if}
- -
+ {/each} + {/if}
{/if} diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 022ba81f5..a4a75c30b 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -327,11 +327,10 @@ messages = messages; return; } - const parentMessage = history.messages[parentId]; - if (!parentMessage.files) { - parentMessage.files = []; + if (!responseMessage.files) { + responseMessage.files = []; } - parentMessage.files.push({ + responseMessage.files.push({ collection_name: searchDocument!.collection_name, name: searchQuery, type: 'websearch', diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index b2cca1653..16afff36c 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -332,11 +332,10 @@ messages = messages; return; } - const parentMessage = history.messages[parentId]; - if (!parentMessage.files) { - parentMessage.files = []; + if (!responseMessage.files) { + responseMessage.files = []; } - parentMessage.files.push({ + responseMessage.files.push({ collection_name: searchDocument!.collection_name, name: searchQuery, type: 'websearch',