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

Function format_push_card

deployments/feishu/daily-push-agent/main.py:1618–1689  ·  view source on GitHub ↗

Format the daily push card with explicit must-read status and drift hint.

(
    scored_papers: List[PaperWithScore],
    profile: Dict = None,
    date: str = None,
    total_fetched: int = None
)

Source from the content-addressed store, hash-verified

1616
1617
1618def format_push_card(
1619 scored_papers: List[PaperWithScore],
1620 profile: Dict = None,
1621 date: str = None,
1622 total_fetched: int = None
1623) -> str:
1624 """Format the daily push card with explicit must-read status and drift hint."""
1625 if date is None:
1626 date = datetime.now().strftime("%m-%d")
1627
1628 must_read = [p for p in scored_papers if p.category == "must_read"]
1629 high_relevant = [p for p in scored_papers if p.category == "high_relevant"]
1630 maybe_interested = [p for p in scored_papers if p.category == "maybe_interested"]
1631 edge_relevant = [p for p in scored_papers if p.category == "edge_relevant"]
1632
1633 total = total_fetched or len(scored_papers)
1634 filtered = len(must_read) + len(high_relevant) + len(maybe_interested) + len(edge_relevant)
1635
1636 lines = [f"📰 今日论文 | {date} | 抓取 {total} 篇 → 筛后 {filtered} 篇", ""]
1637 lines.append(f"━━━ 🔒 必读清单命中({len(must_read)} 篇)━━━")
1638 lines.append(format_must_read_config(profile or {}))
1639 lines.append(format_drift_hint(profile or {}))
1640 reading_signal_hint = format_reading_signal_hint(profile or {})
1641 if reading_signal_hint:
1642 lines.append(reading_signal_hint)
1643
1644 global_count = 0
1645 if must_read:
1646 for paper_with_score in must_read:
1647 global_count += 1
1648 title = str(paper_with_score.paper.get("title", "Unknown") or "Unknown").strip()
1649 authors = paper_with_score.paper.get("authors", [])
1650 categories = paper_with_score.paper.get("categories", [])
1651 category_str = categories[0] if categories else "unknown"
1652 first_author = authors[0].split(",")[0].strip() if isinstance(authors, list) and authors else "Unknown"
1653 lines.append(f"{global_count:02d}. [{category_str}] {first_author} — {title}")
1654 match_reason = format_must_read_reason(paper_with_score.paper, profile or {})
1655 if match_reason:
1656 lines.append(f" 命中:{match_reason}")
1657 else:
1658 must_read_config = (profile or {}).get("must_read", {})
1659 if any(must_read_config.get(key) for key in ("authors", "institutions", "keywords")):
1660 lines.append("本次推送未命中当前必读清单。")
1661 else:
1662 lines.append("当前还没有设置必读作者 / 机构 / 关键词。")
1663 lines.append("")
1664
1665 sections = [
1666 ("🔴", "高度相关", high_relevant),
1667 ("🟡", "可能感兴趣", maybe_interested),
1668 ("🔵", "边缘相关", edge_relevant),
1669 ]
1670 for marker, section_title, items in sections:
1671 if not items:
1672 continue
1673 lines.append(f"━━━ {marker} {section_title}({len(items)} 篇)━━━")
1674 for paper_with_score in items:
1675 global_count += 1

Callers 1

daily_pushFunction · 0.85

Calls 6

format_must_read_configFunction · 0.85
format_drift_hintFunction · 0.85
format_must_read_reasonFunction · 0.85
nowMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected