Spaces:
Paused
Paused
Update final.py
Browse files
final.py
CHANGED
@@ -81,6 +81,9 @@ def process_data(zip_file_name: str, prompt_template) -> Tuple[float, float, int
|
|
81 |
user_wants_to_continue = False
|
82 |
uploaded_file_name = None
|
83 |
|
|
|
|
|
|
|
84 |
@cl.on_chat_start
|
85 |
async def start():
|
86 |
global uploaded_file_name
|
@@ -92,22 +95,20 @@ async def start():
|
|
92 |
content="Please upload a zip file to begin!", accept={"application/zip": [".zip"]}
|
93 |
).send()
|
94 |
|
95 |
-
zip_file
|
96 |
uploaded_file_name = zip_file.name
|
97 |
|
98 |
# Get the CHAINLIT_USER_FILES_DIR from environment variables
|
99 |
user_files_dir = os.environ.get('CHAINLIT_USER_FILES_DIR', '/tmp/chainlit_user_files')
|
100 |
|
101 |
-
#
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
os.makedirs(user_files_dir, exist_ok=True)
|
110 |
-
shutil.move(temp_file_path, os.path.join(user_files_dir, zip_file.name))
|
111 |
|
112 |
# Let the user know that the system is ready
|
113 |
await cl.Message(content=f"`{zip_file.name}` uploaded successfully!").send()
|
|
|
81 |
user_wants_to_continue = False
|
82 |
uploaded_file_name = None
|
83 |
|
84 |
+
import os
|
85 |
+
import shutil
|
86 |
+
|
87 |
@cl.on_chat_start
|
88 |
async def start():
|
89 |
global uploaded_file_name
|
|
|
95 |
content="Please upload a zip file to begin!", accept={"application/zip": [".zip"]}
|
96 |
).send()
|
97 |
|
98 |
+
zip_file = files[0] # Assuming only one file is uploaded
|
99 |
uploaded_file_name = zip_file.name
|
100 |
|
101 |
# Get the CHAINLIT_USER_FILES_DIR from environment variables
|
102 |
user_files_dir = os.environ.get('CHAINLIT_USER_FILES_DIR', '/tmp/chainlit_user_files')
|
103 |
|
104 |
+
# Ensure the user files directory exists
|
105 |
+
os.makedirs(user_files_dir, exist_ok=True)
|
106 |
+
|
107 |
+
# Define the destination path
|
108 |
+
dest_path = os.path.join(user_files_dir, zip_file.name)
|
109 |
+
|
110 |
+
# Copy the file to the destination
|
111 |
+
shutil.copy(zip_file.path, dest_path)
|
|
|
|
|
112 |
|
113 |
# Let the user know that the system is ready
|
114 |
await cl.Message(content=f"`{zip_file.name}` uploaded successfully!").send()
|