处理冷启动
(self, text: str)
| 1662 | send_message(f"{summary}\n\n{profile_message}", chat_id=self.chat_id, user_id=self.feishu_user_id) |
| 1663 | return { |
| 1664 | "success": True, |
| 1665 | "confirmed_direction": canonical_name, |
| 1666 | "updated_topics": [label], |
| 1667 | } |
| 1668 | except Exception as e: |
| 1669 | return {"success": False, "message": str(e)} |
| 1670 | |
| 1671 | def handle_cold_start(self, text: str) -> Dict[str, Any]: |
| 1672 | """处理冷启动""" |
| 1673 | print("Intent: Cold Start") |
| 1674 | |
| 1675 | try: |
| 1676 | coldstart_agent = importlib.import_module("agents.coldstart-agent.main") |
| 1677 | explicit_command = detect_explicit_command_intent(text) |
| 1678 | scholar_url = extract_google_scholar_url(text) |
| 1679 | homepage_url = extract_homepage_url(text) |
| 1680 | natural_language = strip_bootstrap_urls(text) if (scholar_url or homepage_url) else text |
| 1681 | reset_existing = should_reset_existing_profile_for_cold_start(text) |
| 1682 | |
| 1683 | if explicit_command and explicit_command.get("intent") == "cold_start": |
| 1684 | if not scholar_url and not homepage_url: |
| 1685 | natural_language = ( |
| 1686 | self.role_meta.get("natural_language") |
| 1687 | or self.role_meta.get("bootstrap_summary") |
| 1688 | or self.role_meta.get("description") |
| 1689 | or "" |
| 1690 | ).strip() |
| 1691 | elif (scholar_url or homepage_url) and not natural_language: |
| 1692 | natural_language = None |
| 1693 | |
| 1694 | coldstart_agent.cold_start( |
| 1695 | user_id=self.user_id, |
| 1696 | natural_language=natural_language or None, |
| 1697 | scholar_url=scholar_url, |
| 1698 | homepage_url=homepage_url, |
| 1699 | reset_existing=reset_existing, |
| 1700 | send_to_feishu=self.send_to_feishu, |
| 1701 | feishu_user_id=self.feishu_user_id, |
| 1702 | chat_id=self.chat_id |