检测用户意图 Args: text: 用户输入文本 Returns: 意图字典 {"intent": "...", "confidence": 0.0-1.0, "slots": {}}
(self, text: str)
| 1515 | self.chat_id = (chat_id or resolve_role_chat_id(self.user_id, self.profile)) if send_to_feishu else None |
| 1516 | |
| 1517 | def detect_intent(self, text: str) -> Dict[str, Any]: |
| 1518 | """ |
| 1519 | 检测用户意图 |
| 1520 | |
| 1521 | Args: |
| 1522 | text: 用户输入文本 |
| 1523 | |
| 1524 | Returns: |
| 1525 | 意图字典 {"intent": "...", "confidence": 0.0-1.0, "slots": {}} |
| 1526 | """ |
| 1527 | cleaned = first_meaningful_line(text) |
| 1528 | text_lower = cleaned.lower().strip() |
| 1529 | |
| 1530 | if looks_like_bot_authored_message(text): |
| 1531 | return {"intent": "ignore", "confidence": 1.0, "slots": {}} |
| 1532 | |
| 1533 | explicit_command = detect_explicit_command_intent(text) |
| 1534 | if explicit_command: |
| 1535 | return explicit_command |
| 1536 | |
| 1537 | # 角色管理 |
| 1538 | role_keywords = ["角色", "role", "切换", "create role", "删除角色"] |
| 1539 | if any(kw in text_lower for kw in role_keywords): |
| 1540 | return {"intent": "role_manager", "confidence": 0.85, "slots": {"command": text}} |
| 1541 | |
| 1542 | if looks_like_must_read_command(text): |
| 1543 | return {"intent": "must_read", "confidence": 0.95, "slots": {"command": cleaned}} |
| 1544 | |
| 1545 | expand_request = detect_expand_push_request(text) |
| 1546 | if expand_request: |
| 1547 | return {"intent": "expand_push", "confidence": 0.9, "slots": expand_request} |
| 1548 | |
| 1549 | correction_request = detect_classification_correction_request(text) |
| 1550 | if correction_request: |
| 1551 | return {"intent": "classification_correction", "confidence": 0.92, "slots": correction_request} |
| 1552 | |
| 1553 | report_feedback = detect_report_feedback_request(text) |
| 1554 | if report_feedback: |
| 1555 | return {"intent": "report_feedback", "confidence": 0.88, "slots": report_feedback} |
| 1556 | |
| 1557 | reviewer_watch = detect_reviewer_watch_request(text) |
| 1558 | if reviewer_watch: |
| 1559 | return {"intent": "reviewer_watch", "confidence": 0.82, "slots": reviewer_watch} |
| 1560 | |
| 1561 | if looks_like_clear_reading_list_command(text): |
| 1562 | return {"intent": "clear_reading_list", "confidence": 0.95, "slots": {}} |
| 1563 | |
| 1564 | profile_update = parse_profile_update_request(text, profile=self.profile) |
| 1565 | if profile_update: |
| 1566 | return {"intent": "profile_update", "confidence": 0.9, "slots": profile_update} |
| 1567 | |
| 1568 | # 冷启动相关 |
| 1569 | if looks_like_cold_start_description(text, profile=self.profile): |
| 1570 | return {"intent": "cold_start", "confidence": 0.9, "slots": {"text": text}} |
| 1571 | |
| 1572 | # 每日推送 |
| 1573 | push_keywords = ["推送", "daily push", "今日论文", "今天有什么", "来一篇"] |
| 1574 | if any(kw in text_lower for kw in push_keywords): |