Spaces:
Sleeping
Sleeping
Commit
·
c78b8c1
1
Parent(s):
59466bb
fix the issues in the app.py
Browse files
app.py
CHANGED
|
@@ -1160,13 +1160,14 @@ def list_documents(tenant_id: str, role: str, limit: int = 1000, offset: int = 0
|
|
| 1160 |
type_counts[doc_type] += 1
|
| 1161 |
total_length += len(text)
|
| 1162 |
|
| 1163 |
-
|
| 1164 |
-
|
| 1165 |
-
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
-
|
| 1169 |
-
|
|
|
|
| 1170 |
|
| 1171 |
# Create statistics dictionary
|
| 1172 |
stats = {
|
|
@@ -2159,8 +2160,9 @@ with gr.Blocks(
|
|
| 2159 |
status, docs, total, stats, chart_fig = list_documents(tenant_id, role)
|
| 2160 |
|
| 2161 |
# Filter documents by type if not "all"
|
|
|
|
| 2162 |
if filter_type != "all" and docs:
|
| 2163 |
-
filtered_docs = [doc for doc in docs if doc
|
| 2164 |
docs = filtered_docs
|
| 2165 |
status = f"✅ Found {len(docs)} {filter_type} document(s) (out of {total} total)"
|
| 2166 |
|
|
|
|
| 1160 |
type_counts[doc_type] += 1
|
| 1161 |
total_length += len(text)
|
| 1162 |
|
| 1163 |
+
# Format as list for Gradio Dataframe (list of lists)
|
| 1164 |
+
formatted_docs.append([
|
| 1165 |
+
doc_id,
|
| 1166 |
+
doc_type,
|
| 1167 |
+
preview,
|
| 1168 |
+
len(text),
|
| 1169 |
+
created_at[:10] if created_at else "N/A"
|
| 1170 |
+
])
|
| 1171 |
|
| 1172 |
# Create statistics dictionary
|
| 1173 |
stats = {
|
|
|
|
| 2160 |
status, docs, total, stats, chart_fig = list_documents(tenant_id, role)
|
| 2161 |
|
| 2162 |
# Filter documents by type if not "all"
|
| 2163 |
+
# docs is now a list of lists: [ID, Type, Preview, Length, Created]
|
| 2164 |
if filter_type != "all" and docs:
|
| 2165 |
+
filtered_docs = [doc for doc in docs if len(doc) > 1 and doc[1].lower() == filter_type.lower()]
|
| 2166 |
docs = filtered_docs
|
| 2167 |
status = f"✅ Found {len(docs)} {filter_type} document(s) (out of {total} total)"
|
| 2168 |
|