Update app.py
Browse files
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
|
| 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}
|