Spaces:
Paused
Paused
BGarida commited on
Commit ·
b1805d6
1
Parent(s): b4f4511
Deploying PDF Version v18
Browse files
app.py
CHANGED
|
@@ -108,20 +108,26 @@ async def start():
|
|
| 108 |
msg = cl.Message(content=f"Processing `{file.name}`...")
|
| 109 |
await msg.send()
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
# Simulate upload progress
|
| 112 |
for i in range(0, 101, 10):
|
| 113 |
-
await
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
| 118 |
|
| 119 |
try:
|
| 120 |
# Simulate processing progress
|
| 121 |
for i in range(0, 101, 10):
|
| 122 |
-
await
|
| 123 |
-
|
| 124 |
-
await cl.sleep(1)
|
| 125 |
if i == 50:
|
| 126 |
# Actually process the file at the midpoint
|
| 127 |
chunks_with_metadata = process_file(file)
|
|
@@ -153,7 +159,7 @@ async def start():
|
|
| 153 |
)
|
| 154 |
|
| 155 |
cl.user_session.set("chain", chain)
|
| 156 |
-
await
|
| 157 |
|
| 158 |
except Exception as e:
|
| 159 |
error_msg = f"An error occurred while processing the file: {str(e)}"
|
|
|
|
| 108 |
msg = cl.Message(content=f"Processing `{file.name}`...")
|
| 109 |
await msg.send()
|
| 110 |
|
| 111 |
+
# Create a progress bar for upload
|
| 112 |
+
upload_progress = cl.Progress(total=100, description="Uploading")
|
| 113 |
+
await upload_progress.send()
|
| 114 |
+
|
| 115 |
# Simulate upload progress
|
| 116 |
for i in range(0, 101, 10):
|
| 117 |
+
await upload_progress.update(i)
|
| 118 |
+
await cl.sleep(0.5)
|
| 119 |
+
|
| 120 |
+
await cl.Message(content=f"Upload complete. Now processing `{file.name}`...").send()
|
| 121 |
|
| 122 |
+
# Create a progress bar for processing
|
| 123 |
+
process_progress = cl.Progress(total=100, description="Processing")
|
| 124 |
+
await process_progress.send()
|
| 125 |
|
| 126 |
try:
|
| 127 |
# Simulate processing progress
|
| 128 |
for i in range(0, 101, 10):
|
| 129 |
+
await process_progress.update(i)
|
| 130 |
+
await cl.sleep(1)
|
|
|
|
| 131 |
if i == 50:
|
| 132 |
# Actually process the file at the midpoint
|
| 133 |
chunks_with_metadata = process_file(file)
|
|
|
|
| 159 |
)
|
| 160 |
|
| 161 |
cl.user_session.set("chain", chain)
|
| 162 |
+
await cl.Message(content=f"Processing `{file.name}` complete. You can now ask questions about the book!").send()
|
| 163 |
|
| 164 |
except Exception as e:
|
| 165 |
error_msg = f"An error occurred while processing the file: {str(e)}"
|