Spaces:
Runtime error
Runtime error
Update main.py
Browse files- app/main.py +10 -8
- app/rag.py +1 -0
app/main.py
CHANGED
@@ -59,14 +59,16 @@ async def parse_body(request: Request):
|
|
59 |
|
60 |
@app.post("/upload")
|
61 |
def upload(data: bytes = Depends(parse_body)):
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
f
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
|
71 |
message = "Files inserted successfully."
|
72 |
generator = re.split(r'(\s)', message)
|
|
|
59 |
|
60 |
@app.post("/upload")
|
61 |
def upload(data: bytes = Depends(parse_body)):
|
62 |
+
print("Data : " + data)
|
63 |
+
if data:
|
64 |
+
try:
|
65 |
+
path = f"{files_dir}/file"
|
66 |
+
with open(path, "wb") as f:
|
67 |
+
f.write(data)
|
68 |
+
session_assistant.ingest(files_dir)
|
69 |
+
pathlib.Path(path).unlink()
|
70 |
+
except Exception as e:
|
71 |
+
logging.error(traceback.format_exc())
|
72 |
|
73 |
message = "Files inserted successfully."
|
74 |
generator = re.split(r'(\s)', message)
|
app/rag.py
CHANGED
@@ -107,6 +107,7 @@ class ChatPDF:
|
|
107 |
return streaming_response
|
108 |
|
109 |
def clear(self):
|
|
|
110 |
if self.nodes:
|
111 |
self.vector_store.delete_nodes(self.nodes)
|
112 |
self.pdf_count = 0
|
|
|
107 |
return streaming_response
|
108 |
|
109 |
def clear(self):
|
110 |
+
# self.vector_store.clear()
|
111 |
if self.nodes:
|
112 |
self.vector_store.delete_nodes(self.nodes)
|
113 |
self.pdf_count = 0
|