aadil732 commited on
Commit
7dea390
·
verified ·
1 Parent(s): f822bf6

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +4 -4
api.py CHANGED
@@ -188,7 +188,7 @@ async def root(query: str, proffesion: str):
188
  return response_generator(query, proffesion)
189
 
190
  @app.post("/upload_document")
191
- async def upload_document(file_bytes: bytes = File(...), file_name: str = "document.pdf"):
192
  """
193
  FastAPI endpoint to handle POST requests for uploading a document to the Pinecone index.
194
 
@@ -202,13 +202,13 @@ async def upload_document(file_bytes: bytes = File(...), file_name: str = "docum
202
  try:
203
 
204
  # Ensure the 'uploaded' directory exists
205
- os.makedirs('./uploaded', exist_ok=True)
206
 
207
  # Save the uploaded file
208
- with open('./uploaded'+file_name, "wb") as f:
209
  f.write(file_bytes)
210
 
211
- description = uploading_document_to_pinecone(file_name)
212
  response = requests.post("http://0.0.0.0:8080/send_desc", files={"description": description})
213
  return {"status": description}
214
  except Exception as e:
 
188
  return response_generator(query, proffesion)
189
 
190
  @app.post("/upload_document")
191
+ async def upload_document(file_bytes: bytes = File(...)):
192
  """
193
  FastAPI endpoint to handle POST requests for uploading a document to the Pinecone index.
194
 
 
202
  try:
203
 
204
  # Ensure the 'uploaded' directory exists
205
+ # os.makedirs('./uploaded', exist_ok=True)
206
 
207
  # Save the uploaded file
208
+ with open("/tmp/document.pdf", "wb") as f:
209
  f.write(file_bytes)
210
 
211
+ description = uploading_document_to_pinecone("/tmp/document.pdf")
212
  response = requests.post("http://0.0.0.0:8080/send_desc", files={"description": description})
213
  return {"status": description}
214
  except Exception as e: