Spaces:
Running
Running
fix
Browse files- app/main.py +5 -4
app/main.py
CHANGED
@@ -37,19 +37,20 @@ def process_input(text: str):
|
|
37 |
def upload(files: list[UploadFile]):
|
38 |
session_assistant.clear()
|
39 |
session_messages = []
|
|
|
40 |
|
41 |
try:
|
42 |
-
os.makedirs(
|
43 |
for file in files:
|
44 |
try:
|
45 |
file.file.seek(0)
|
46 |
-
with Path(
|
47 |
shutil.copyfileobj(file.file, destination)
|
48 |
finally:
|
49 |
file.file.close()
|
50 |
finally:
|
51 |
-
session_assistant.ingest(
|
52 |
-
shutil.rmtree(
|
53 |
|
54 |
return "Files inserted!"
|
55 |
|
|
|
37 |
def upload(files: list[UploadFile]):
|
38 |
session_assistant.clear()
|
39 |
session_messages = []
|
40 |
+
files_dir = os.path.expanduser("~/wtp_be_files/")
|
41 |
|
42 |
try:
|
43 |
+
os.makedirs(files_dir)
|
44 |
for file in files:
|
45 |
try:
|
46 |
file.file.seek(0)
|
47 |
+
with Path(files_dir).open("wb") as destination:
|
48 |
shutil.copyfileobj(file.file, destination)
|
49 |
finally:
|
50 |
file.file.close()
|
51 |
finally:
|
52 |
+
session_assistant.ingest(files_dir)
|
53 |
+
shutil.rmtree(files_dir)
|
54 |
|
55 |
return "Files inserted!"
|
56 |
|