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

Function start_reading_reports_task

deployments/desktop/shared/agents.py:2753–2818  ·  view source on GitHub ↗
(
    *,
    user_id: str,
    push_id: str,
    paper_numbers: Iterable[Any],
    write_feishu: Optional[bool] = None,
    response_language: str = "zh",
)

Source from the content-addressed store, hash-verified

2751
2752 with _READING_TASK_LOCK:
2753 task = _READING_TASKS.get(task_id)
2754 if task:
2755 task["status"] = "failed" if errors and not completed_docs else "completed"
2756 task["progress_phase"] = task["status"]
2757 task["completed_docs"] = completed_docs
2758 task["errors"] = errors
2759 task["completed_at"] = _task_timestamp()
2760 task["updated_at"] = task["completed_at"]
2761
2762
2763def start_reading_reports_task(
2764 *,
2765 user_id: str,
2766 push_id: str,
2767 paper_numbers: Iterable[Any],
2768 write_feishu: Optional[bool] = None,
2769 response_language: str = "zh",
2770) -> Dict[str, Any]:
2771 push = db_ops.get_push_papers(push_id)
2772 if not push or not push.get("papers"):
2773 raise ValueError(f"Push not found: {push_id}")
2774 papers = list(push["papers"])
2775 selected = _unique_ints(paper_numbers, maximum=len(papers))
2776 selected_papers = reading_agent.resolve_selected_papers(selected, papers)
2777 docs: List[Dict[str, Any]] = []
2778 language = _normalize_response_language(response_language)
2779 for paper in selected_papers:
2780 normalized_paper = reading_agent._normalize_paper(paper) # noqa: SLF001
2781 report_path = _reading_placeholder_path(user_id, normalized_paper)
2782 _write_reading_placeholder(
2783 user_id=user_id,
2784 paper=normalized_paper,
2785 report_path=report_path,
2786 status="queued",
2787 steps=["已加入后台精读队列。", _reading_language_notice(language), "刷新本页面可查看最新进度。"],
2788 response_language=language,
2789 )
2790 docs.append(
2791 {
2792 "title": f"[精读] {normalized_paper.get('title', 'Unknown')[:80]}",
2793 "url": None,
2794 "doc_token": None,
2795 "report_path": str(report_path),
2796 "pdf_path": normalized_paper.get("pdf_path"),
2797 "paper": normalized_paper,
2798 "paper_raw": normalized_paper,
2799 "report_payload": {"generation_provider": "paperflow", "generation_model": "background-reading-task"},
2800 }
2801 )
2802
2803 task_id = f"reading_{datetime.now().strftime('%Y%m%d_%H%M%S')}_{uuid4().hex[:8]}"
2804 now = _task_timestamp()
2805 task: Dict[str, Any] = {
2806 "task_id": task_id,
2807 "kind": "reading_reports",
2808 "status": "queued",
2809 "progress_phase": "queued",
2810 "user_id": user_id,

Callers 1

submit_and_readFunction · 0.85

Calls 11

_unique_intsFunction · 0.85
_reading_language_noticeFunction · 0.85
_task_timestampFunction · 0.85
_doc_payloadsFunction · 0.85
_reading_task_payloadFunction · 0.85
getMethod · 0.80
nowMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected