Spaces:
Running
Running
mateoluksenberg
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -340,36 +340,36 @@ def simple_chat(message: dict, temperature: float = 0.8, max_length: int = 4096,
|
|
340 |
|
341 |
|
342 |
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
#
|
349 |
-
|
350 |
-
#
|
351 |
-
|
352 |
-
|
353 |
|
354 |
-
#
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
#
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
|
368 |
-
#
|
369 |
-
|
370 |
-
|
371 |
|
372 |
-
|
373 |
|
374 |
|
375 |
with gr.Blocks(css=CSS, theme="soft", fill_height=True) as demo:
|
|
|
340 |
|
341 |
|
342 |
|
343 |
+
@app.post("/chat/")
|
344 |
+
async def test_endpoint(
|
345 |
+
text: str = Form(...),
|
346 |
+
file: UploadFile = File(None)
|
347 |
+
):
|
348 |
+
# Verificar si se ha subido un archivo
|
349 |
+
if file:
|
350 |
+
# Leer el archivo en memoria
|
351 |
+
file_content = BytesIO(await file.read())
|
352 |
+
file_name = file.filename
|
353 |
|
354 |
+
# Construir el mensaje con el archivo y el texto
|
355 |
+
message = {
|
356 |
+
"text": text,
|
357 |
+
"file_content": file_content,
|
358 |
+
"file_name": file_name
|
359 |
+
}
|
360 |
+
else:
|
361 |
+
# Si no se sube archivo, solo se incluye el texto
|
362 |
+
message = {
|
363 |
+
"text": text,
|
364 |
+
"file_content": None,
|
365 |
+
"file_name": None
|
366 |
+
}
|
367 |
|
368 |
+
# Llamar a la función `simple_chat` con el mensaje
|
369 |
+
print(message)
|
370 |
+
response = simple_chat(message)
|
371 |
|
372 |
+
return response
|
373 |
|
374 |
|
375 |
with gr.Blocks(css=CSS, theme="soft", fill_height=True) as demo:
|