KingNish commited on
Commit
27fd504
·
verified ·
1 Parent(s): 106195e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -167,11 +167,22 @@ async def fast_ai(user: str, model: str = "llama3-70b", system: str = "Answer as
167
  except Exception as e:
168
  raise HTTPException(status_code=500, detail=f"Error during Snova AI request: {e}")
169
 
 
 
 
 
 
 
 
 
 
 
 
170
  @app.post("/api/fastAI-post")
171
- async def fast_ai(user: str, model: str = "llama3-70b", system: str = "Answer as concisely as possible."):
172
  """Get a response from the Snova AI service."""
173
  try:
174
- response = await asyncio.to_thread(fastai, user, model, system)
175
  return JSONResponse(content={"response": response})
176
  except Exception as e:
177
  raise HTTPException(status_code=500, detail=f"Error during Snova AI request: {e}")
 
167
  except Exception as e:
168
  raise HTTPException(status_code=500, detail=f"Error during Snova AI request: {e}")
169
 
170
+ from pydantic import BaseModel
171
+ import asyncio
172
+
173
+ app = FastAPI()
174
+
175
+ # Define a Pydantic model for the request payload
176
+ class FastAIRequest(BaseModel):
177
+ user: str
178
+ model: str = "llama3-70b"
179
+ system: str = "Answer as concisely as possible."
180
+
181
  @app.post("/api/fastAI-post")
182
+ async def fast_ai(request: FastAIRequest):
183
  """Get a response from the Snova AI service."""
184
  try:
185
+ response = await asyncio.to_thread(fastai, request.user, request.model, request.system)
186
  return JSONResponse(content={"response": response})
187
  except Exception as e:
188
  raise HTTPException(status_code=500, detail=f"Error during Snova AI request: {e}")