From 27045f52f913d51354172a6c784e8f74f841a7c7 Mon Sep 17 00:00:00 2001 From: chigkim Date: Sun, 18 Feb 2024 10:19:26 -0500 Subject: [PATCH] Better error message when no nodes found for Semantic Search. --- RAG.py | 10 +++++++--- VOLlama.py | 2 +- changelog.md | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/RAG.py b/RAG.py index 37e60fc..f300b29 100644 --- a/RAG.py +++ b/RAG.py @@ -76,6 +76,10 @@ def ask(self, question): self.token_counter.reset_counts() self.update_settings(self.host, self.llm_name) node_postprocessors = [SimilarityPostprocessor(similarity_cutoff=settings.similarity_cutoff)] - query_engine = self.index.as_query_engine(similarity_top_k=settings.similarity_top_k, node_postprocessors = node_postprocessors, response_mode=settings.response_mode, streaming=True) - self.response = query_engine.query(question) - return self.response.response_gen + query_engine = self.index.as_query_engine(similarity_top_k=settings.similarity_top_k, node_postprocessors = node_postprocessors, response_mode='no_text') + response = query_engine.query(question) + if response.source_nodes: + query_engine = self.index.as_query_engine(similarity_top_k=settings.similarity_top_k, node_postprocessors = node_postprocessors, response_mode=settings.response_mode, streaming=True) + self.response = query_engine.query(question) + return self.response.response_gen + raise Exception("No texts found for the question using the current rag settings") \ No newline at end of file diff --git a/VOLlama.py b/VOLlama.py index 6575191..62936b5 100644 --- a/VOLlama.py +++ b/VOLlama.py @@ -1,4 +1,4 @@ -version = 12 +version = 13 import wx import threading import sounddevice as sd diff --git a/changelog.md b/changelog.md index 6697dbf..b9c9818 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # Change log +* Better error message for when no text found from semantic search. * Index file * Fixed bug when index gets reset when changing model * Token counter on the status bar for RAG.