Spaces:
Sleeping
Sleeping
Update app.py
#2
by
ZunairaHawwar
- opened
app.py
CHANGED
|
@@ -703,11 +703,17 @@ def ingest_docs_to_chroma():
|
|
| 703 |
|
| 704 |
# Add Chunks to ChromaDB
|
| 705 |
for chunk in chunks:
|
| 706 |
-
content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
metadata = chunk.metadata
|
| 708 |
doc_id = str(hash(content))
|
| 709 |
collection.add(documents=[content], metadatas=[metadata], ids=[doc_id])
|
| 710 |
|
|
|
|
| 711 |
st.success("✅ Knowledge Base Updated Successfully!")
|
| 712 |
|
| 713 |
# --- Search embedded knowledge ---
|
|
|
|
| 703 |
|
| 704 |
# Add Chunks to ChromaDB
|
| 705 |
for chunk in chunks:
|
| 706 |
+
# Flatten list content if necessary
|
| 707 |
+
if isinstance(chunk.page_content, list):
|
| 708 |
+
content = " ".join(str(item) for item in chunk.page_content).strip()
|
| 709 |
+
else:
|
| 710 |
+
content = str(chunk.page_content).strip()
|
| 711 |
+
|
| 712 |
metadata = chunk.metadata
|
| 713 |
doc_id = str(hash(content))
|
| 714 |
collection.add(documents=[content], metadatas=[metadata], ids=[doc_id])
|
| 715 |
|
| 716 |
+
|
| 717 |
st.success("✅ Knowledge Base Updated Successfully!")
|
| 718 |
|
| 719 |
# --- Search embedded knowledge ---
|