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

Function _finish_reading_task

deployments/desktop/shared/agents.py:2673–2750  ·  view source on GitHub ↗
(task_id: str)

Source from the content-addressed store, hash-verified

2671) -> Dict[str, Any]:
2672 normalized_arxiv_id = _normalize_arxiv_id(arxiv_id)
2673 paper = db_ops.get_paper_by_arxiv_id(normalized_arxiv_id)
2674 if not paper:
2675 detail = arxiv_fetcher.get_paper_detail(normalized_arxiv_id)
2676 if not detail:
2677 raise ValueError(f"Could not fetch arXiv paper: {normalized_arxiv_id}")
2678 paper_id = db_ops.save_paper(
2679 arxiv_id=detail.get("arxiv_id") or normalized_arxiv_id,
2680 doi=detail.get("doi"),
2681 title=detail.get("title") or normalized_arxiv_id,
2682 authors=detail.get("authors") or [],
2683 abstract=detail.get("abstract") or "",
2684 categories=detail.get("categories") or [],
2685 source="arxiv",
2686 publish_date=detail.get("publish_date"),
2687 )
2688 paper = {**detail, "id": paper_id, "source": "arxiv"}
2689
2690 should_write_feishu = _env_bool("PAPERFLOW_WRITE_FEISHU", default=False) if write_feishu is None else bool(write_feishu)
2691 language = _normalize_response_language(response_language)
2692 with _reading_agent_output_env_patch(), _local_only_feishu_doc_patch(not should_write_feishu):
2693 docs = reading_agent.create_reading_report(
2694 user_id=user_id,
2695 paper_ids=[],
2696 papers=[paper],
2697 send_to_feishu=should_write_feishu,
2698 request_metadata={
2699 "report_source_type": "desktop_arxiv",
2700 "report_source_key": normalized_arxiv_id,
2701 "report_source_name": normalized_arxiv_id,
2702 "report_style": _configured_report_style(),
2703 "response_language": language,
2704 },
2705 )
2706 wiki_backfilled = _backfill_docs_to_wiki(user_id, docs)
2707 payload = _reports_payload(docs, write_feishu_requested=should_write_feishu)
2708 payload["wiki_backfilled"] = wiki_backfilled
2709 return payload
2710
2711
2712def read_local_pdf(
2713 user_id: str,
2714 pdf_path: str,
2715 title: str = "",
2716 write_feishu: Optional[bool] = None,
2717 response_language: str = "zh",
2718) -> Dict[str, Any]:
2719 path = Path(str(pdf_path or "")).expanduser()
2720 if not path.is_absolute():
2721 path = PROJECT_ROOT / path
2722 if not path.exists() or not path.is_file():
2723 raise ValueError(f"PDF not found: {path}")
2724
2725 paper = {
2726 "title": title.strip() or path.stem,
2727 "authors": [],
2728 "abstract": "",
2729 "source": "local_pdf",
2730 "pdf_path": str(path),

Callers

nothing calls this directly

Calls 5

_task_timestampFunction · 0.85
_reading_language_noticeFunction · 0.85
create_reading_reportsFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected