Update routes/chatbot_routes.py
Browse files- routes/chatbot_routes.py +7 -2
routes/chatbot_routes.py
CHANGED
|
@@ -1,17 +1,22 @@
|
|
| 1 |
# routes/chatbot_routes.py
|
| 2 |
from fastapi import APIRouter
|
| 3 |
from pydantic import BaseModel
|
| 4 |
-
from intents import detect_intent, extract_keywords
|
| 5 |
|
| 6 |
router = APIRouter()
|
| 7 |
|
| 8 |
class ChatIn(BaseModel):
|
| 9 |
message: str
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
@router.post("/chatbot")
|
| 12 |
async def chatbot(in_: ChatIn):
|
| 13 |
text = (in_.message or "").strip()
|
| 14 |
intent, entities = detect_intent(text)
|
|
|
|
| 15 |
|
| 16 |
if intent == "create_quote_from_pyc":
|
| 17 |
reply = "Bạn muốn tạo báo giá từ **phiếu yêu cầu**. Hãy cung cấp số PYC hoặc chọn PYC trong danh sách."
|
|
@@ -70,7 +75,7 @@ async def chatbot(in_: ChatIn):
|
|
| 70 |
|
| 71 |
if intent == "help":
|
| 72 |
reply = ("Bạn có thể hỏi:\n"
|
| 73 |
-
"- \"báo giá\" / \"tạo báo giá từ PYC 140\" / \"bảng giá hóa lý\"\n"
|
| 74 |
"- \"PYC chờ xử lý\" / \"PYC đã hoàn thành\"\n"
|
| 75 |
"- \"doanh thu\" / \"quản lý hóa chất\" / \"hồ sơ lưu\" / \"tài liệu\"")
|
| 76 |
return {"reply": reply, "intent": intent, "action": "none", "params": {}}
|
|
|
|
| 1 |
# routes/chatbot_routes.py
|
| 2 |
from fastapi import APIRouter
|
| 3 |
from pydantic import BaseModel
|
| 4 |
+
from intents import detect_intent, extract_keywords
|
| 5 |
|
| 6 |
router = APIRouter()
|
| 7 |
|
| 8 |
class ChatIn(BaseModel):
|
| 9 |
message: str
|
| 10 |
|
| 11 |
+
@router.get("/chatbot/ping")
|
| 12 |
+
def chatbot_ping():
|
| 13 |
+
return {"ok": True}
|
| 14 |
+
|
| 15 |
@router.post("/chatbot")
|
| 16 |
async def chatbot(in_: ChatIn):
|
| 17 |
text = (in_.message or "").strip()
|
| 18 |
intent, entities = detect_intent(text)
|
| 19 |
+
print(f"[chatbot] msg='{text}' -> intent={intent}, entities={entities}") # <=== LOG
|
| 20 |
|
| 21 |
if intent == "create_quote_from_pyc":
|
| 22 |
reply = "Bạn muốn tạo báo giá từ **phiếu yêu cầu**. Hãy cung cấp số PYC hoặc chọn PYC trong danh sách."
|
|
|
|
| 75 |
|
| 76 |
if intent == "help":
|
| 77 |
reply = ("Bạn có thể hỏi:\n"
|
| 78 |
+
"- \"báo giá\" / \"giá thiết bị ...\" / \"tạo báo giá từ PYC 140\" / \"bảng giá hóa lý\"\n"
|
| 79 |
"- \"PYC chờ xử lý\" / \"PYC đã hoàn thành\"\n"
|
| 80 |
"- \"doanh thu\" / \"quản lý hóa chất\" / \"hồ sơ lưu\" / \"tài liệu\"")
|
| 81 |
return {"reply": reply, "intent": intent, "action": "none", "params": {}}
|