处理用户输入 Args: text: 用户输入文本 Returns: 处理结果
(self, text: str)
| 2442 | return {"success": False, "message": "Unknown intent"} |
| 2443 | |
| 2444 | def process(self, text: str) -> Dict[str, Any]: |
| 2445 | """ |
| 2446 | 处理用户输入 |
| 2447 | |
| 2448 | Args: |
| 2449 | text: 用户输入文本 |
| 2450 | |
| 2451 | Returns: |
| 2452 | 处理结果 |
| 2453 | """ |
| 2454 | text_clean = safe_console_text(text, 100) |
| 2455 | print(f"\n{'='*60}") |
| 2456 | print(f"Processing: {text_clean}") |
| 2457 | print(f"{'='*60}") |
| 2458 | |
| 2459 | # 检测意图 |
| 2460 | intent = self.detect_intent(text) |
| 2461 | print(f"Detected intent: {intent['intent']} (confidence: {intent['confidence']:.2f})") |
| 2462 | |
| 2463 | # 路由到对应处理器 |
| 2464 | handlers = { |
| 2465 | "ignore": lambda: {"success": True, "ignored": True}, |
| 2466 | "confirm_direction": lambda: self.handle_confirm_direction(intent["slots"].get("topic", text)), |
| 2467 | "cold_start": lambda: self.handle_cold_start(text), |
| 2468 | "daily_push": self.handle_daily_push, |
| 2469 | "feedback": lambda: self.handle_feedback(intent["slots"].get("reply", text)), |
| 2470 | "expand_push": lambda: self.handle_expand_push( |
| 2471 | category=intent["slots"].get("category", ""), |
| 2472 | query=intent["slots"].get("query", ""), |
| 2473 | ), |
| 2474 | "classification_correction": lambda: self.handle_classification_correction( |
| 2475 | int(intent["slots"].get("paper_number", 0)), |
| 2476 | intent["slots"].get("target_category", ""), |
| 2477 | ), |
| 2478 | "report_feedback": lambda: self.handle_report_feedback(intent["slots"].get("sentiment", "")), |
| 2479 | "reviewer_watch": lambda: self.handle_reviewer_watch( |
| 2480 | intent["slots"].get("conference", ""), |
| 2481 | int(intent["slots"].get("year", datetime.now().year)), |
| 2482 | text, |
| 2483 | ), |
| 2484 | "reading_report": lambda: self.handle_reading_report( |
| 2485 | paper_ids=intent["slots"].get("paper_ids"), |
| 2486 | pdf_url=intent["slots"].get("pdf_url"), |
| 2487 | title_hint=intent["slots"].get("title_hint", ""), |
| 2488 | ), |
| 2489 | "clear_reading_list": self.handle_clear_reading_list, |
| 2490 | "weekly_report": self.handle_weekly_report, |
| 2491 | "must_read": lambda: self.handle_must_read(intent["slots"].get("command", text)), |
| 2492 | "show_profile": self.handle_show_profile, |
| 2493 | "profile_update": lambda: self.handle_profile_update(text, intent["slots"]), |
| 2494 | "role_manager": lambda: self.handle_role_manager(intent["slots"].get("command", text)), |
| 2495 | } |
| 2496 | |
| 2497 | handler = handlers.get(intent["intent"], lambda: self.handle_unknown(text)) |
| 2498 | result = handler() |
| 2499 | |
| 2500 | print(f"Result: {safe_console_text(result, 200)}") |
| 2501 | return result |
no test coverage detected