Chanjeans commited on
Commit
ce7592f
Β·
verified Β·
1 Parent(s): 3536ce6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1103,14 +1103,17 @@ def recommend_api(profile: UserProfile):
1103
  })
1104
  return {"recommendations": results}
1105
 
1106
- # (3) 챗봇 Endpoint
1107
  class ChatRequest(BaseModel):
1108
  user_input: str
1109
- mode: str = "emotion"
1110
 
1111
  @app.post("/chat")
1112
  def chat_api(req: ChatRequest):
1113
  user_text = req.user_input
1114
- mode = req.mode
 
 
 
1115
  reply = chat_response(user_text, mode=mode)
1116
  return {"response": reply}
 
1103
  })
1104
  return {"recommendations": results}
1105
 
1106
+ # (3) 챗봇 Endpoint (emotion/rational 선택 κ°€λŠ₯)
1107
  class ChatRequest(BaseModel):
1108
  user_input: str
1109
+ mode: str # `emotion` λ˜λŠ” `rational`을 λͺ…ν™•ν•˜κ²Œ μž…λ ₯받도둝 μ„€μ •
1110
 
1111
  @app.post("/chat")
1112
  def chat_api(req: ChatRequest):
1113
  user_text = req.user_input
1114
+ mode = req.mode.lower() # μž…λ ₯을 μ†Œλ¬Έμžλ‘œ λ³€ν™˜ν•΄ 톡일성 μœ μ§€
1115
+ if mode not in ["emotion", "rational"]:
1116
+ raise HTTPException(status_code=400, detail="modeλŠ” 'emotion' λ˜λŠ” 'rational'이어야 ν•©λ‹ˆλ‹€.")
1117
+
1118
  reply = chat_response(user_text, mode=mode)
1119
  return {"response": reply}