Spaces:
Running
Running
Update app.py
Browse files
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(
|
346 |
-
if
|
347 |
raise HTTPException(status_code=400, detail="Missing 'text' in request body")
|
348 |
|
349 |
-
if
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
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:
|