Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -293,6 +293,7 @@ def split_into_chunks(texts, references, chunk_size, chunk_overlap):
|
|
| 293 |
# return vectorstore
|
| 294 |
|
| 295 |
|
|
|
|
| 296 |
def setup_vectorstore(chunks, model_name):
|
| 297 |
print("Start setup_vectorstore_function")
|
| 298 |
|
|
@@ -311,33 +312,26 @@ def setup_vectorstore(chunks, model_name):
|
|
| 311 |
print("Persist directory:", vectorstore._persist_directory)
|
| 312 |
print("Available methods in vectorstore:", dir(vectorstore))
|
| 313 |
|
| 314 |
-
#
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
path_in_repo=target_path_in_repo,
|
| 335 |
-
repo_id=HF_SPACE_NAME,
|
| 336 |
-
repo_type="space"
|
| 337 |
-
)
|
| 338 |
-
print(f"Uploaded {zip_file_path} as {target_path_in_repo}")
|
| 339 |
-
|
| 340 |
-
break # Stop after processing the first subfolder
|
| 341 |
|
| 342 |
print("Process completed successfully!")
|
| 343 |
|
|
|
|
| 293 |
# return vectorstore
|
| 294 |
|
| 295 |
|
| 296 |
+
|
| 297 |
def setup_vectorstore(chunks, model_name):
|
| 298 |
print("Start setup_vectorstore_function")
|
| 299 |
|
|
|
|
| 312 |
print("Persist directory:", vectorstore._persist_directory)
|
| 313 |
print("Available methods in vectorstore:", dir(vectorstore))
|
| 314 |
|
| 315 |
+
# Zip the entire folder
|
| 316 |
+
zip_file_path = os.path.join(temp_dir, "folder_archive.zip")
|
| 317 |
+
with zipfile.ZipFile(zip_file_path, "w", zipfile.ZIP_DEFLATED) as zipf:
|
| 318 |
+
for folder_root, _, folder_files in os.walk(temp_dir):
|
| 319 |
+
for file_name in folder_files:
|
| 320 |
+
file_path = os.path.join(folder_root, file_name)
|
| 321 |
+
arcname = os.path.relpath(file_path, temp_dir) # Preserve relative paths
|
| 322 |
+
zipf.write(file_path, arcname)
|
| 323 |
+
|
| 324 |
+
print(f"Created zip file: {zip_file_path}")
|
| 325 |
+
|
| 326 |
+
# Upload the zip file
|
| 327 |
+
target_path_in_repo = "folder_archive.zip" # Define the target name in the repository
|
| 328 |
+
api.upload_file(
|
| 329 |
+
path_or_fileobj=zip_file_path,
|
| 330 |
+
path_in_repo=target_path_in_repo,
|
| 331 |
+
repo_id=HF_SPACE_NAME,
|
| 332 |
+
repo_type="space"
|
| 333 |
+
)
|
| 334 |
+
print(f"Uploaded {zip_file_path} as {target_path_in_repo}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
|
| 336 |
print("Process completed successfully!")
|
| 337 |
|