Skip to content

Commit

Permalink
feat(nl-to-mquery): throw 400 if can not translate question to mquery
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHaoJun committed Sep 26, 2024
1 parent 94fac39 commit a5dad9e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ async def get_mquery(request: Request, question: str = Query(..., description="Q
raise HTTPException(status_code=400, detail="question is required")
if num_tokens > 300:
raise HTTPException(status_code=400, detail="question tokens over limit 300")
return {"questionNumTokens": num_tokens, "mquery": nl_to_mquery(question)}
mquery = nl_to_mquery(question)
if not mquery:
raise HTTPException(status_code=400, detail="Can not find pokemon")
return {"questionNumTokens": num_tokens, "mquery": mquery}

@app.get("/health")
async def get_mquery(request: Request):
Expand Down

0 comments on commit a5dad9e

Please sign in to comment.