MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / cold_start

Function cold_start

agents/coldstart-agent/main.py:1732–1869  ·  view source on GitHub ↗

Execute the cold-start / PDF-update flow.

(
    user_id: str = "user_001",
    natural_language: Optional[str] = None,
    pdf_paths: Optional[List[str]] = None,
    scholar_url: Optional[str] = None,
    homepage_url: Optional[str] = None,
    reset_existing: bool = False,
    send_to_feishu: bool = True,
    feishu_user_id: Optional[str] = None,
    chat_id: Optional[str] = None,
)

Source from the content-addressed store, hash-verified

1730
1731
1732def cold_start(
1733 user_id: str = "user_001",
1734 natural_language: Optional[str] = None,
1735 pdf_paths: Optional[List[str]] = None,
1736 scholar_url: Optional[str] = None,
1737 homepage_url: Optional[str] = None,
1738 reset_existing: bool = False,
1739 send_to_feishu: bool = True,
1740 feishu_user_id: Optional[str] = None,
1741 chat_id: Optional[str] = None,
1742) -> Dict[str, Any]:
1743 """Execute the cold-start / PDF-update flow."""
1744 print(f"Starting cold start for user: {user_id}")
1745
1746 existing_profile = get_profile(user_id)
1747 if existing_profile and not reset_existing:
1748 profile = ensure_profile_shape(existing_profile, user_id)
1749 print("Loaded existing profile as merge base.")
1750 else:
1751 profile = build_empty_profile(user_id)
1752 if existing_profile and reset_existing:
1753 print("Resetting existing profile before cold start.")
1754
1755 baseline_pdf_path = None
1756 try:
1757 baseline_pdf_path = _seed_profile_from_baseline_pdf(profile, user_id)
1758 if baseline_pdf_path:
1759 print(f"Seeded profile from baseline PDF: {baseline_pdf_path}")
1760 except Exception as exc:
1761 print(f"Failed to seed baseline PDF: {exc}")
1762
1763 if natural_language:
1764 print("Parsing natural language...")
1765 parsed = parse_natural_language(natural_language)
1766 merge_parsed_profile_into_profile(profile, parsed)
1767
1768 if pdf_paths:
1769 print(f"Parsing {len(pdf_paths)} PDF file(s)...")
1770 applied_sources = set()
1771 if baseline_pdf_path:
1772 applied_sources.add(str(Path(baseline_pdf_path).resolve()))
1773
1774 for pdf_path in pdf_paths:
1775 if not os.path.exists(pdf_path):
1776 print(f" PDF not found: {pdf_path}")
1777 continue
1778
1779 resolved_path = str(Path(pdf_path).resolve())
1780 if resolved_path in applied_sources:
1781 print(f" Skipping duplicate source PDF: {pdf_path}")
1782 continue
1783
1784 try:
1785 result = parse_paper_for_coldstart(pdf_path)
1786 merge_pdf_result_into_profile(profile, result)
1787 applied_sources.add(resolved_path)
1788 print(f" Parsed: {pdf_path}")
1789 except Exception as exc:

Callers 1

main.pyFile · 0.85

Calls 15

ensure_profile_shapeFunction · 0.85
parse_natural_languageFunction · 0.85
parse_research_homepageFunction · 0.85
generate_interest_vectorFunction · 0.85
update_profileFunction · 0.85
create_profileFunction · 0.85

Tested by

no test coverage detected