(
*,
user_id: str,
push_id: str,
paper_numbers: Iterable[Any],
write_feishu: Optional[bool] = None,
response_language: str = "zh",
)
| 2455 | doc_url=doc.get("url") or metadata.get("doc_url"), |
| 2456 | doc_token=doc.get("doc_token") or metadata.get("doc_token"), |
| 2457 | ) |
| 2458 | except Exception as exc: |
| 2459 | doc["wiki_ingest_error"] = str(exc) |
| 2460 | continue |
| 2461 | if result: |
| 2462 | doc["wiki_ingest"] = result |
| 2463 | backfilled += 1 |
| 2464 | return backfilled |
| 2465 | |
| 2466 | |
| 2467 | def create_reading_reports( |
| 2468 | *, |
| 2469 | user_id: str, |
| 2470 | push_id: str, |
| 2471 | paper_numbers: Iterable[Any], |
| 2472 | write_feishu: Optional[bool] = None, |
| 2473 | response_language: str = "zh", |
| 2474 | ) -> Dict[str, Any]: |
| 2475 | push = db_ops.get_push_papers(push_id) |
| 2476 | if not push or not push.get("papers"): |
| 2477 | raise ValueError(f"Push not found: {push_id}") |
| 2478 | papers = list(push["papers"]) |
| 2479 | selected = _unique_ints(paper_numbers, maximum=len(papers)) |
| 2480 | should_write_feishu = _env_bool("PAPERFLOW_WRITE_FEISHU", default=False) if write_feishu is None else bool(write_feishu) |
| 2481 | language = _normalize_response_language(response_language) |
| 2482 | if not selected: |
| 2483 | return _reports_payload([], write_feishu_requested=should_write_feishu) |
| 2484 | |
| 2485 | with _reading_agent_output_env_patch(), _local_only_feishu_doc_patch(not should_write_feishu): |
| 2486 | docs = reading_agent.create_reading_report( |
| 2487 | user_id=user_id, |
| 2488 | paper_ids=selected, |
| 2489 | papers=papers, |
| 2490 | send_to_feishu=should_write_feishu, |
| 2491 | request_metadata={ |
| 2492 | "selection_push_id": push_id, |
| 2493 | "report_source_type": "desktop_gui", |
| 2494 | "report_style": _configured_report_style(), |
| 2495 | "response_language": language, |
no test coverage detected