dkdaniz commited on
Commit
d13603d
1 Parent(s): 0f6a428

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -4
main.py CHANGED
@@ -91,7 +91,7 @@ async def predict(data: Predict):
91
  (os.path.basename(str(document.metadata["source"])), str(document.page_content))
92
  )
93
 
94
- return {response: prompt_response_dict}
95
  else:
96
  raise HTTPException(status_code=400, detail="Prompt Incorrect")
97
 
@@ -102,9 +102,9 @@ def run_ingest_route():
102
  try:
103
  shutil.rmtree(PERSIST_DIRECTORY)
104
  except OSError as e:
105
- print(f"Error: {e.filename} - {e.strerror}.")
106
  else:
107
- print("The directory does not exist")
108
 
109
  run_langest_commands = ["python", "ingest.py"]
110
  if DEVICE_TYPE == "cpu":
@@ -134,7 +134,9 @@ def run_ingest_route():
134
  "prompt": prompt,
135
  },
136
  )
137
- return "Script executed successfully: {}".format(result.stdout.decode("utf-8"))
 
 
138
  except Exception as e:
139
  raise HTTPException(status_code=500, detail=f"Error occurred: {str(e)}")
140
 
 
91
  (os.path.basename(str(document.metadata["source"])), str(document.page_content))
92
  )
93
 
94
+ return {"response": prompt_response_dict}
95
  else:
96
  raise HTTPException(status_code=400, detail="Prompt Incorrect")
97
 
 
102
  try:
103
  shutil.rmtree(PERSIST_DIRECTORY)
104
  except OSError as e:
105
+ raise HTTPException(status_code=500, detail=f"Error: {e.filename} - {e.strerror}.")
106
  else:
107
+ raise HTTPException(status_code=500, detail="The directory does not exist")
108
 
109
  run_langest_commands = ["python", "ingest.py"]
110
  if DEVICE_TYPE == "cpu":
 
134
  "prompt": prompt,
135
  },
136
  )
137
+
138
+ response = "Script executed successfully: {}".format(result.stdout.decode("utf-8"))
139
+ return {"response": response}
140
  except Exception as e:
141
  raise HTTPException(status_code=500, detail=f"Error occurred: {str(e)}")
142