Spaces:
Sleeping
Sleeping
Update chatbot_rag.py
Browse files- 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 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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):
|