Fast-path obvious commands so they never go through the profile-update LLM.
(text: Any)
| 783 | |
| 784 | |
| 785 | def detect_explicit_command_intent(text: Any) -> Optional[Dict[str, Any]]: |
| 786 | """Fast-path obvious commands so they never go through the profile-update LLM.""" |
| 787 | cleaned = first_meaningful_line(text) |
| 788 | lowered = cleaned.lower().strip() |
| 789 | if not lowered: |
| 790 | return None |
| 791 | |
| 792 | confirmed_direction = parse_confirm_direction_request(cleaned) |
| 793 | if confirmed_direction: |
| 794 | return { |
| 795 | "intent": "confirm_direction", |
| 796 | "confidence": 1.0, |
| 797 | "slots": {"topic": confirmed_direction}, |
| 798 | } |
| 799 | |
| 800 | cold_start_commands = {"cold start", "cold-start", "冷启动", "重新冷启动"} |
| 801 | daily_push_commands = {"daily push", "推送", "今日论文", "今天论文", "来一篇", "来几篇"} |
| 802 | reading_commands = {"read this", "deep read", "精读"} |
| 803 | weekly_report_commands = {"weekly report", "周报"} |
| 804 | must_read_commands = {"必读", "必读清单"} |
| 805 | profile_commands = { |
| 806 | "profile", |
| 807 | "画像", |
| 808 | "学术画像", |
| 809 | "我的画像", |
| 810 | "我的学术画像", |
| 811 | "显示画像", |
| 812 | "显示学术画像", |
| 813 | } |
| 814 | feedback_commands = {"all red", "all lock", "none", "全部", "没有"} |
| 815 | |
| 816 | scholar_url = extract_google_scholar_url(cleaned) |
| 817 | if scholar_url: |
| 818 | return { |
| 819 | "intent": "cold_start", |
| 820 | "confidence": 1.0, |
| 821 | "slots": {"text": cleaned, "scholar_url": scholar_url}, |
| 822 | } |
| 823 | |
| 824 | pdf_url = extract_pdf_url(text) |
| 825 | if pdf_url: |
| 826 | return { |
| 827 | "intent": "reading_report", |
| 828 | "confidence": 1.0, |
| 829 | "slots": { |
| 830 | "pdf_url": pdf_url, |
| 831 | "title_hint": normalize_direct_pdf_title_hint(strip_pdf_url(text)), |
| 832 | }, |
| 833 | } |
| 834 | |
| 835 | homepage_url = extract_homepage_url(cleaned) |
| 836 | if homepage_url: |
| 837 | return { |
| 838 | "intent": "cold_start", |
| 839 | "confidence": 1.0, |
| 840 | "slots": {"text": cleaned, "homepage_url": homepage_url}, |
| 841 | } |
| 842 |
no test coverage detected