Update app.py
Browse files
app.py
CHANGED
|
@@ -110,7 +110,7 @@ def list_uploaded_files_paginated(page_num=0, progress=gr.Progress()):
|
|
| 110 |
progress(0.5, desc="π Processing page...")
|
| 111 |
|
| 112 |
# Pagination settings
|
| 113 |
-
files_per_page =
|
| 114 |
start_idx = page_num * files_per_page
|
| 115 |
end_idx = start_idx + files_per_page
|
| 116 |
|
|
@@ -122,73 +122,24 @@ def list_uploaded_files_paginated(page_num=0, progress=gr.Progress()):
|
|
| 122 |
# Create summary
|
| 123 |
summary = f"π **Files Summary (Page {page_num + 1} of {total_pages})**\n\n"
|
| 124 |
summary += f"π **Total files:** {total_files}\n"
|
| 125 |
-
summary += f"π **Showing:** {start_idx + 1}-{min(end_idx, total_files)} of {total_files}\n"
|
| 126 |
-
summary += f"π **Last updated:** {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n"
|
| 127 |
|
| 128 |
-
#
|
| 129 |
-
|
| 130 |
-
summary += f"π **Files on this page:**\n"
|
| 131 |
-
for i, file_obj in enumerate(page_files, 1):
|
| 132 |
-
file_name = getattr(file_obj, 'name', 'Unknown')
|
| 133 |
-
created_on = getattr(file_obj, 'created_on', 'Unknown')
|
| 134 |
-
try:
|
| 135 |
-
if created_on != 'Unknown':
|
| 136 |
-
created_formatted = parse_pinecone_timestamp(created_on).strftime('%m-%d %H:%M')
|
| 137 |
-
else:
|
| 138 |
-
created_formatted = 'Unknown'
|
| 139 |
-
except:
|
| 140 |
-
created_formatted = 'Unknown'
|
| 141 |
-
summary += f"{start_idx + i}. {file_name} ({created_formatted})\n"
|
| 142 |
-
summary += "\n"
|
| 143 |
-
|
| 144 |
-
# Create detailed file list for current page only
|
| 145 |
-
detailed_info = f"## π **File Details - Page {page_num + 1}**\n\n"
|
| 146 |
|
| 147 |
-
progress(0.8, desc="π Formatting
|
| 148 |
|
| 149 |
for i, file_obj in enumerate(page_files, 1):
|
| 150 |
try:
|
| 151 |
-
# Get
|
| 152 |
-
file_name = getattr(file_obj, 'name', 'Unknown')
|
| 153 |
-
file_id = getattr(file_obj, 'id', 'Unknown')
|
| 154 |
-
file_size = getattr(file_obj, 'size', 0)
|
| 155 |
-
created_on = getattr(file_obj, 'created_on', 'Unknown')
|
| 156 |
-
updated_on = getattr(file_obj, 'updated_on', created_on)
|
| 157 |
-
|
| 158 |
-
# Format file size
|
| 159 |
-
if file_size > 1024 * 1024:
|
| 160 |
-
size_str = f"{file_size / (1024 * 1024):.2f} MB"
|
| 161 |
-
elif file_size > 1024:
|
| 162 |
-
size_str = f"{file_size / 1024:.2f} KB"
|
| 163 |
-
else:
|
| 164 |
-
size_str = f"{file_size} bytes"
|
| 165 |
-
|
| 166 |
-
# Format timestamps
|
| 167 |
-
try:
|
| 168 |
-
if created_on != 'Unknown':
|
| 169 |
-
created_formatted = parse_pinecone_timestamp(created_on).strftime('%Y-%m-%d %H:%M:%S UTC')
|
| 170 |
-
else:
|
| 171 |
-
created_formatted = 'Unknown'
|
| 172 |
-
|
| 173 |
-
if updated_on != 'Unknown' and updated_on != created_on:
|
| 174 |
-
updated_formatted = parse_pinecone_timestamp(updated_on).strftime('%Y-%m-%d %H:%M:%S UTC')
|
| 175 |
-
else:
|
| 176 |
-
updated_formatted = created_formatted
|
| 177 |
-
except Exception as e:
|
| 178 |
-
created_formatted = str(created_on)
|
| 179 |
-
updated_formatted = str(updated_on)
|
| 180 |
-
|
| 181 |
global_index = start_idx + i
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
detailed_info += f"
|
| 185 |
-
detailed_info += f"- **π
Uploaded:** {created_formatted}\n"
|
| 186 |
-
detailed_info += f"- **π Last Updated:** {updated_formatted}\n"
|
| 187 |
-
detailed_info += "\n---\n\n"
|
| 188 |
|
| 189 |
except Exception as file_error:
|
| 190 |
-
detailed_info += f"
|
| 191 |
-
detailed_info += f"- **Error:** {str(file_error)}\n\n---\n\n"
|
| 192 |
|
| 193 |
# Pagination info
|
| 194 |
pagination_info = f"π Page {page_num + 1} of {total_pages} | Total: {total_files} files"
|
|
@@ -648,7 +599,7 @@ with gr.Blocks(
|
|
| 648 |
# Pagination controls
|
| 649 |
with gr.Row():
|
| 650 |
prev_btn = gr.Button(
|
| 651 |
-
"
|
| 652 |
variant="secondary",
|
| 653 |
visible=False
|
| 654 |
)
|
|
@@ -657,7 +608,7 @@ with gr.Blocks(
|
|
| 657 |
elem_classes=["pagination-info"]
|
| 658 |
)
|
| 659 |
next_btn = gr.Button(
|
| 660 |
-
"Next
|
| 661 |
variant="secondary",
|
| 662 |
visible=False
|
| 663 |
)
|
|
|
|
| 110 |
progress(0.5, desc="π Processing page...")
|
| 111 |
|
| 112 |
# Pagination settings
|
| 113 |
+
files_per_page = 100 # Changed to 100
|
| 114 |
start_idx = page_num * files_per_page
|
| 115 |
end_idx = start_idx + files_per_page
|
| 116 |
|
|
|
|
| 122 |
# Create summary
|
| 123 |
summary = f"π **Files Summary (Page {page_num + 1} of {total_pages})**\n\n"
|
| 124 |
summary += f"π **Total files:** {total_files}\n"
|
| 125 |
+
summary += f"π **Showing:** {start_idx + 1}-{min(end_idx, total_files)} of {total_files}\n\n"
|
|
|
|
| 126 |
|
| 127 |
+
# Create file list - ONLY TITLES, VERTICALLY
|
| 128 |
+
detailed_info = f"## π **Latest Uploaded Files - Page {page_num + 1}**\n\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
+
progress(0.8, desc="π Formatting file titles...")
|
| 131 |
|
| 132 |
for i, file_obj in enumerate(page_files, 1):
|
| 133 |
try:
|
| 134 |
+
# Get only the file name/title
|
| 135 |
+
file_name = getattr(file_obj, 'name', 'Unknown File')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
global_index = start_idx + i
|
| 137 |
+
|
| 138 |
+
# Display only the title vertically
|
| 139 |
+
detailed_info += f"{global_index}. **{file_name}**\n\n"
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
except Exception as file_error:
|
| 142 |
+
detailed_info += f"{start_idx + i}. β **Error loading file**\n\n"
|
|
|
|
| 143 |
|
| 144 |
# Pagination info
|
| 145 |
pagination_info = f"π Page {page_num + 1} of {total_pages} | Total: {total_files} files"
|
|
|
|
| 599 |
# Pagination controls
|
| 600 |
with gr.Row():
|
| 601 |
prev_btn = gr.Button(
|
| 602 |
+
"β¬
οΈ Previous 100",
|
| 603 |
variant="secondary",
|
| 604 |
visible=False
|
| 605 |
)
|
|
|
|
| 608 |
elem_classes=["pagination-info"]
|
| 609 |
)
|
| 610 |
next_btn = gr.Button(
|
| 611 |
+
"Next 100 β‘οΈ",
|
| 612 |
variant="secondary",
|
| 613 |
visible=False
|
| 614 |
)
|