From c0bb32d76820fbb6b46fd214c4a06b1d6bdd8c73 Mon Sep 17 00:00:00 2001 From: Yanyutin753 <132346501+Yanyutin753@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:51:30 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8C=20fixed=20a=20bug=20where=20RAG=20?= =?UTF-8?q?would=20not=20reply=20after=20not=20reading=20the=20file=20corr?= =?UTF-8?q?ectly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apps/rag/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/apps/rag/utils.py b/backend/apps/rag/utils.py index 10f1f7bed..9941eb46c 100644 --- a/backend/apps/rag/utils.py +++ b/backend/apps/rag/utils.py @@ -321,8 +321,12 @@ def rag_messages( context_string = "" for context in relevant_contexts: - items = context["documents"][0] - context_string += "\n\n".join(items) + try: + if "documents" in context: + items = [item for item in context["documents"][0] if item is not None] + context_string += "\n\n".join(items) + except Exception as e: + log.exception(e) context_string = context_string.strip() ra_content = rag_template(