mateoluksenberg commited on
Commit
0e13882
·
verified ·
1 Parent(s): f80b970

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -342,19 +342,23 @@ def simple_chat(message: dict, file_obj: io.BytesIO = None, temperature: float =
342
 
343
 
344
  @app.post("/chat/")
345
- async def test_endpoint(message: dict):
346
- if "text" not in message:
347
  raise HTTPException(status_code=400, detail="Missing 'text' in request body")
348
 
349
- if "file" in message and message["file"]:
350
- file_url = message["file"]
351
  file_obj = download_file(file_url)
352
  if file_obj is None:
353
  raise HTTPException(status_code=400, detail="Failed to download file from URL")
354
  else:
355
  file_obj = None
356
 
357
- response = simple_chat(message, file_obj)
 
 
 
 
 
358
  return response
359
 
360
  def download_file(url: str) -> io.BytesIO:
 
342
 
343
 
344
  @app.post("/chat/")
345
+ async def test_endpoint(text: str, file_url: str = None):
346
+ if not text:
347
  raise HTTPException(status_code=400, detail="Missing 'text' in request body")
348
 
349
+ if file_url:
 
350
  file_obj = download_file(file_url)
351
  if file_obj is None:
352
  raise HTTPException(status_code=400, detail="Failed to download file from URL")
353
  else:
354
  file_obj = None
355
 
356
+ print("Mensaje: ")
357
+ print(text)
358
+ print("File: ")
359
+ print(file_obj)
360
+
361
+ response = simple_chat(text, file_obj)
362
  return response
363
 
364
  def download_file(url: str) -> io.BytesIO: