Subha95 commited on
Commit
be17c77
·
verified ·
1 Parent(s): 3f1a962

Update chatbot_rag.py

Browse files
Files changed (1) hide show
  1. chatbot_rag.py +6 -2
chatbot_rag.py CHANGED
@@ -95,8 +95,12 @@ def build_qa():
95
 
96
  # 6. Helper functions
97
  def format_docs(docs):
98
- # skip any docs where page_content is None
99
- return "\n".join(d.page_content for d in docs if d.page_content)
 
 
 
 
100
 
101
 
102
  def hf_to_str(x):
 
95
 
96
  # 6. Helper functions
97
  def format_docs(docs):
98
+ """Join document contents into a single string, skipping empty ones."""
99
+ texts = []
100
+ for doc in docs:
101
+ if doc.page_content and isinstance(doc.page_content, str):
102
+ texts.append(doc.page_content.strip())
103
+ return "\n".join(texts)
104
 
105
 
106
  def hf_to_str(x):