(
*,
user_id: str,
paper: Dict[str, Any],
report_path: Path,
status: str,
steps: Iterable[str],
error: str = "",
response_language: str = "zh",
)
| 2611 | category="reading_reports", |
| 2612 | ) |
| 2613 | target_dir.mkdir(parents=True, exist_ok=True) |
| 2614 | obsidian_report = target_dir.name.startswith("Deep Reading - ") |
| 2615 | stem = ( |
| 2616 | reading_agent._paper_title_file_stem(paper) # noqa: SLF001 |
| 2617 | if obsidian_report |
| 2618 | else f"{reading_agent._paper_file_stem(paper)} - reading-report" # noqa: SLF001 |
| 2619 | ) |
| 2620 | return target_dir / f"{stem}.md" |
| 2621 | |
| 2622 | |
| 2623 | def _write_reading_placeholder( |
| 2624 | *, |
| 2625 | user_id: str, |
| 2626 | paper: Dict[str, Any], |
| 2627 | report_path: Path, |
| 2628 | status: str, |
| 2629 | steps: Iterable[str], |
| 2630 | error: str = "", |
| 2631 | response_language: str = "zh", |
| 2632 | ) -> None: |
| 2633 | title = str(paper.get("title") or report_path.stem).strip() or report_path.stem |
| 2634 | now = datetime.now().isoformat(timespec="seconds") |
| 2635 | is_en = _normalize_response_language(response_language) == "en" |
| 2636 | status_title = "Reading in progress" if is_en else "正在精读中" |
| 2637 | if status == "failed": |
| 2638 | status_title = "Reading failed" if is_en else "精读失败" |
| 2639 | elif status == "queued": |
| 2640 | status_title = "Reading in progress" if is_en else "正在精读中" |
| 2641 | frontmatter = { |
| 2642 | "user_id": user_id, |
| 2643 | "paper_id": paper.get("id"), |
| 2644 | "arxiv_id": paper.get("arxiv_id"), |
| 2645 | "doi": paper.get("doi"), |
| 2646 | "title": title, |
| 2647 | "publish_date": paper.get("publish_date"), |
| 2648 | "pdf_url": paper.get("pdf_url"), |
| 2649 | "abs_url": paper.get("abs_url") or paper.get("paper_url") or paper.get("url"), |
| 2650 | "generation_provider": "paperflow", |
| 2651 | "generation_model": "background-reading-task", |
| 2652 | "report_version": "in-progress", |
| 2653 | "report_status": status, |
| 2654 | "saved_at": now, |
| 2655 | "updated_at": now, |
| 2656 | } |
| 2657 | lines = ["---"] |
| 2658 | for key, value in frontmatter.items(): |
| 2659 | if value not in (None, "", [], {}): |
| 2660 | lines.append(f"{key}: {json.dumps(value, ensure_ascii=False)}") |
| 2661 | lines.extend(["---", "", f"# {title}", "", f"> {status_title}", "", "## 进度" if not is_en else "## Progress", ""]) |
no test coverage detected