mitulagr2 commited on
Commit
bc3c00d
1 Parent(s): bc8f854

Update main.py

Browse files
Files changed (2) hide show
  1. app/main.py +10 -8
  2. 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
- try:
63
- path = f"{files_dir}/file"
64
- with open(path, "wb") as f:
65
- f.write(data)
66
- session_assistant.ingest(files_dir)
67
- pathlib.Path(path).unlink()
68
- except Exception as e:
69
- logging.error(traceback.format_exc())
 
 
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