From d06d19498b4052e03db2a855cbbc956651a99a1b Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 17 Dec 2024 12:51:42 +0330 Subject: [PATCH] feat: Added default message for no data source! --- subquery.py | 7 +++++-- utils/globals.py | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/subquery.py b/subquery.py index f68ac3d..d69060b 100644 --- a/subquery.py +++ b/subquery.py @@ -7,7 +7,7 @@ from llama_index.question_gen.guidance import GuidanceQuestionGenerator from tc_hivemind_backend.db.utils.preprocess_text import BasePreprocessor from tc_hivemind_backend.embeddings.cohere import CohereEmbedding -from utils.globals import INVALID_QUERY_RESPONSE +from utils.globals import INVALID_QUERY_RESPONSE, NO_ANSWER_REFERENCE from utils.qdrant_utils import QDrantUtils from utils.query_engine import ( DEFAULT_GUIDANCE_SUB_QUESTION_PROMPT_TMPL, @@ -228,4 +228,7 @@ def query_multiple_source( ) response, source_nodes = result - return response.response, source_nodes + if source_nodes == []: + return NO_ANSWER_REFERENCE, source_nodes + else: + return response.response, source_nodes diff --git a/utils/globals.py b/utils/globals.py index aa558f7..0758c31 100644 --- a/utils/globals.py +++ b/utils/globals.py @@ -5,3 +5,7 @@ "We're unable to process your query. Please refine it and try again." ) QUERY_ERROR_MESSAGE = "Sorry, we're unable to process your question at the moment. Please try again later." +NO_ANSWER_REFERENCE = ( + "Current documentation and community chats draw a blank. " + "Please ask the community manager for intel and we'll take notes for next time 🙂" +)