Spaces:
Running
Running
mateoluksenberg
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -253,34 +253,18 @@ def simple_chat(message: dict, temperature: float = 0.8, max_length: int = 4096,
|
|
253 |
except Exception as e:
|
254 |
return PlainTextResponse(f"Error: {str(e)}")
|
255 |
|
256 |
-
# @app.post("/chat/")
|
257 |
-
# async def test_endpoint(message: dict):
|
258 |
-
# if "text" not in message:
|
259 |
-
# raise HTTPException(status_code=400, detail="Missing 'text' in request body")
|
260 |
-
|
261 |
-
# if "file" not in message:
|
262 |
-
# print("Sin File")
|
263 |
-
|
264 |
-
# response = simple_chat(message)
|
265 |
-
# return response
|
266 |
-
|
267 |
@app.post("/chat/")
|
268 |
-
async def
|
269 |
-
text
|
270 |
-
file: Optional[UploadFile] = File(None)
|
271 |
-
):
|
272 |
-
if not text:
|
273 |
raise HTTPException(status_code=400, detail="Missing 'text' in request body")
|
274 |
|
275 |
-
if file:
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
print("No file provided")
|
280 |
-
|
281 |
-
response = simple_chat({"text": text, "file_content": file_content if file else None})
|
282 |
return response
|
283 |
|
|
|
284 |
with gr.Blocks(css=CSS, theme="soft", fill_height=True) as demo:
|
285 |
gr.HTML(TITLE)
|
286 |
gr.HTML(DESCRIPTION)
|
|
|
253 |
except Exception as e:
|
254 |
return PlainTextResponse(f"Error: {str(e)}")
|
255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
@app.post("/chat/")
|
257 |
+
async def test_endpoint(message: dict):
|
258 |
+
if "text" not in message:
|
|
|
|
|
|
|
259 |
raise HTTPException(status_code=400, detail="Missing 'text' in request body")
|
260 |
|
261 |
+
if "file" not in message:
|
262 |
+
print("Sin File")
|
263 |
+
|
264 |
+
response = simple_chat(message)
|
|
|
|
|
|
|
265 |
return response
|
266 |
|
267 |
+
|
268 |
with gr.Blocks(css=CSS, theme="soft", fill_height=True) as demo:
|
269 |
gr.HTML(TITLE)
|
270 |
gr.HTML(DESCRIPTION)
|