Yhhxhfh commited on
Commit
fadc2ea
1 Parent(s): fea594a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -8,10 +8,10 @@ import urllib3
8
  import pickle
9
  from functools import lru_cache
10
  from dotenv import load_dotenv
11
- from fastapi import FastAPI, Request
12
  from fastapi.responses import JSONResponse
13
  import time
14
- from tqdm import tqdm # Importando tqdm
15
 
16
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
17
 
@@ -137,9 +137,13 @@ async def process_message(message):
137
  async def api_generate_multimodel(request: Request):
138
  try:
139
  data = await request.json()
140
- message = data["message"]
 
 
141
  response = await process_message(message)
142
  return JSONResponse({"response": response})
 
 
143
  except Exception as e:
144
  return JSONResponse({"error": str(e)}, status_code=500)
145
 
 
8
  import pickle
9
  from functools import lru_cache
10
  from dotenv import load_dotenv
11
+ from fastapi import FastAPI, Request, HTTPException
12
  from fastapi.responses import JSONResponse
13
  import time
14
+ from tqdm import tqdm
15
 
16
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
17
 
 
137
  async def api_generate_multimodel(request: Request):
138
  try:
139
  data = await request.json()
140
+ message = data.get("message")
141
+ if not message:
142
+ raise HTTPException(status_code=400, detail="Mensaje faltante")
143
  response = await process_message(message)
144
  return JSONResponse({"response": response})
145
+ except HTTPException as e:
146
+ raise e
147
  except Exception as e:
148
  return JSONResponse({"error": str(e)}, status_code=500)
149