浏览代码

Merge pull request #1868 from Yanyutin753/rag-dev

📌 fixed a bug where RAG would not reply after not reading the file correctly
Timothy Jaeryang Baek 1 年之前
父节点
当前提交
3f0fae1d10
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      backend/apps/rag/utils.py

+ 6 - 2
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(