(query: str, *, user_id: Optional[str] = None)
| 810 | |
| 811 | |
| 812 | def confirm_pending_direction_candidate(query: str, *, user_id: Optional[str] = None) -> Optional[Dict[str, Any]]: |
| 813 | candidate = find_pending_direction_candidate(query, user_id=user_id) |
| 814 | if not candidate: |
| 815 | return None |
| 816 | |
| 817 | canonical_name = candidate.get("canonical_name") or candidate.get("candidate_key") |
| 818 | add_new_direction( |
| 819 | direction_key=str(canonical_name), |
| 820 | name=str(candidate.get("name") or canonical_name), |
| 821 | name_cn=str(candidate.get("name_cn") or candidate.get("name") or canonical_name), |
| 822 | aliases=list(candidate.get("source_texts", []) or []), |
| 823 | paper_terms=list(candidate.get("paper_terms", []) or candidate.get("source_texts", []) or []), |
| 824 | keywords=list(candidate.get("paper_terms", []) or candidate.get("source_texts", []) or []), |
| 825 | source_text=str((candidate.get("source_texts") or [""])[0]), |
| 826 | ) |
| 827 | |
| 828 | store = _load_pending_store() |
| 829 | candidate_key = str(candidate.get("candidate_key") or "") |
| 830 | if candidate_key in store: |
| 831 | store.pop(candidate_key, None) |
| 832 | _save_pending_store(store) |
| 833 | |
| 834 | return get_direction_entry(str(canonical_name)) |
| 835 | |
| 836 | |
| 837 | if __name__ == "__main__": |
no test coverage detected