소스 검색

📌 fixed a bug where RAG would not reply after not reading the file correctly

Yanyutin753 1 년 전
부모
커밋
c0bb32d768
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(