Route free-form self-descriptions to cold start only when bootstrap is actually needed.
(text: Any, profile: Optional[Dict[str, Any]] = None)
| 1279 | |
| 1280 | |
| 1281 | def looks_like_cold_start_description(text: Any, profile: Optional[Dict[str, Any]] = None) -> bool: |
| 1282 | """Route free-form self-descriptions to cold start only when bootstrap is actually needed.""" |
| 1283 | cleaned = first_meaningful_line(text) |
| 1284 | lowered = cleaned.lower().strip() |
| 1285 | if not lowered: |
| 1286 | return False |
| 1287 | |
| 1288 | if looks_like_bot_authored_message(cleaned): |
| 1289 | return False |
| 1290 | |
| 1291 | if lowered in {"冷启动", "重新冷启动", "cold start", "cold-start"}: |
| 1292 | return True |
| 1293 | |
| 1294 | if any(token in lowered for token in ("初始画像", "设置方向")): |
| 1295 | return True |
| 1296 | |
| 1297 | if extract_google_scholar_url(cleaned): |
| 1298 | return True |
| 1299 | if extract_homepage_url(cleaned): |
| 1300 | return True |
| 1301 | |
| 1302 | if profile and not profile_needs_bootstrap(profile): |
| 1303 | return False |
| 1304 | |
| 1305 | return any(token in cleaned for token in COLD_START_BOOTSTRAP_HINTS) or any( |
| 1306 | token in lowered for token in COLD_START_BOOTSTRAP_HINTS |
| 1307 | ) |
| 1308 | |
| 1309 | |
| 1310 | def should_reset_existing_profile_for_cold_start(text: Any) -> bool: |
no test coverage detected