From e39c4bd9e6ce27e648ba7e8821e454d416a2ce4b Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Wed, 1 May 2024 13:28:02 -0700 Subject: [PATCH 1/2] if document is pinned, do not give queryRefusalResponse message --- server/utils/chats/index.js | 8 ++++++-- server/utils/chats/stream.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/server/utils/chats/index.js b/server/utils/chats/index.js index 87d96c47cab..9f92c534769 100644 --- a/server/utils/chats/index.js +++ b/server/utils/chats/index.js @@ -141,9 +141,13 @@ async function chatWithWorkspace( contextTexts = [...contextTexts, ...vectorSearchResults.contextTexts]; sources = [...sources, ...vectorSearchResults.sources]; - // If in query mode and no sources are found, do not + // If in query mode and no sources are found from the vector search and no pinned documents, do not // let the LLM try to hallucinate a response or use general knowledge and exit early - if (chatMode === "query" && sources.length === 0) { + if ( + chatMode === "query" && + vectorSearchResults.sources.length === 0 && + pinnedDocIdentifiers.length === 0 + ) { return { id: uuid, type: "textResponse", diff --git a/server/utils/chats/stream.js b/server/utils/chats/stream.js index 0e471161a2a..a4559f043f2 100644 --- a/server/utils/chats/stream.js +++ b/server/utils/chats/stream.js @@ -156,9 +156,13 @@ async function streamChatWithWorkspace( contextTexts = [...contextTexts, ...vectorSearchResults.contextTexts]; sources = [...sources, ...vectorSearchResults.sources]; - // If in query mode and no sources are found, do not + // If in query mode and no sources are found from the vector search and no pinned documents, do not // let the LLM try to hallucinate a response or use general knowledge and exit early - if (chatMode === "query" && sources.length === 0) { + if ( + chatMode === "query" && + sources.length === 0 && + pinnedDocIdentifiers.length === 0 + ) { writeResponseChunk(response, { id: uuid, type: "textResponse", From f48da4f4a165c4250ee998450ddc508b2eb44ee8 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Wed, 1 May 2024 17:34:07 -0700 Subject: [PATCH 2/2] forgot embed.js patch --- server/utils/chats/embed.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/utils/chats/embed.js b/server/utils/chats/embed.js index 533ea0c3473..98b096fb1c3 100644 --- a/server/utils/chats/embed.js +++ b/server/utils/chats/embed.js @@ -131,7 +131,11 @@ async function streamChatWithForEmbed( // If in query mode and no sources are found, do not // let the LLM try to hallucinate a response or use general knowledge - if (chatMode === "query" && sources.length === 0) { + if ( + chatMode === "query" && + sources.length === 0 && + pinnedDocIdentifiers.length === 0 + ) { writeResponseChunk(response, { id: uuid, type: "textResponse",