mateoluksenberg commited on
Commit
8c8c54e
·
verified ·
1 Parent(s): 9412c08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -23
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 chat_endpoint(
269
- text: str = Form(...),
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
- file_content = await file.read()
277
- # Procesa el archivo como necesites
278
- else:
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)