Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -131,11 +131,26 @@ print("#1")
|
|
| 131 |
|
| 132 |
# Step 3: Prepare documents (unchanged)
|
| 133 |
def prepare_documents_for_chroma(embeddings):
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
|
| 141 |
print("#2")
|
|
|
|
| 131 |
|
| 132 |
# Step 3: Prepare documents (unchanged)
|
| 133 |
def prepare_documents_for_chroma(embeddings):
|
| 134 |
+
status_text = st.empty()
|
| 135 |
+
progress_bar = st.progress(0)
|
| 136 |
+
documents = []
|
| 137 |
+
|
| 138 |
+
total_entries = len(embeddings)
|
| 139 |
+
|
| 140 |
+
for i, entry in enumerate(embeddings, start=1):
|
| 141 |
+
doc = Document2(
|
| 142 |
+
page_content=entry["chunk"],
|
| 143 |
+
metadata={"chunk_index": i}
|
| 144 |
+
)
|
| 145 |
+
documents.append(doc)
|
| 146 |
+
|
| 147 |
+
progress = i / total_entries
|
| 148 |
+
progress_bar.progress(progress)
|
| 149 |
+
status_text.text(f"Processing document {i}/{total_entries} ({progress:.0%})")
|
| 150 |
+
|
| 151 |
+
progress_bar.progress(1.0)
|
| 152 |
+
status_text.text(f"✅ Successfully prepared {total_entries} documents")
|
| 153 |
+
return documents
|
| 154 |
|
| 155 |
|
| 156 |
print("#2")
|