| 2984 | if not push or not push.get("papers"): |
| 2985 | raise ValueError(f"Push not found: {push_id}") |
| 2986 | papers = list(push["papers"]) |
| 2987 | selected = _unique_ints(paper_numbers, maximum=len(papers)) |
| 2988 | selected_papers = reading_agent.resolve_selected_papers(selected, papers) |
| 2989 | docs: List[Dict[str, Any]] = [] |
| 2990 | language = _normalize_response_language(response_language) |
| 2991 | for paper in selected_papers: |
| 2992 | normalized_paper = reading_agent._normalize_paper(paper) # noqa: SLF001 |
| 2993 | report_path = _reading_placeholder_path(user_id, normalized_paper) |
| 2994 | _write_reading_placeholder( |
| 2995 | user_id=user_id, |
| 2996 | paper=normalized_paper, |
| 2997 | report_path=report_path, |
| 2998 | status="queued", |
| 2999 | steps=["已加入后台精读队列。", _reading_language_notice(language), "刷新本页面可查看最新进度。"], |
| 3000 | response_language=language, |
| 3001 | ) |
| 3002 | docs.append( |
| 3003 | { |
| 3004 | "title": f"[精读] {normalized_paper.get('title', 'Unknown')[:80]}", |
| 3005 | "url": None, |
| 3006 | "doc_token": None, |
| 3007 | "report_path": str(report_path), |
| 3008 | "pdf_path": normalized_paper.get("pdf_path"), |
| 3009 | "paper": normalized_paper, |
| 3010 | "paper_raw": normalized_paper, |
| 3011 | "report_payload": {"generation_provider": "paperflow", "generation_model": "background-reading-task"}, |
| 3012 | } |
| 3013 | ) |
| 3014 | |
| 3015 | task_id = f"reading_{datetime.now().strftime('%Y%m%d_%H%M%S')}_{uuid4().hex[:8]}" |
| 3016 | now = _task_timestamp() |
| 3017 | task: Dict[str, Any] = { |
| 3018 | "task_id": task_id, |
| 3019 | "kind": "reading_reports", |