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

1616def format_reading_signal_hint(profile: Dict) -> str:
1617 """Render a short hint for direct-upload reading signals."""
1618 reading_signal_state = (profile or {}).get("reading_signal_state", {}) or {}
1619 short_term_topics = reading_signal_state.get("short_term_topics", {}) or {}
1620 if not short_term_topics:
1621 return ""
1622
1623 ranked_topics = sorted(
1624 short_term_topics.items(),
1625 key=lambda item: float(item[1] or 0.0),
1626 reverse=True,
1627 )
1628 topic_labels = [format_direction_label(topic) for topic, _ in ranked_topics[:3]]
1629 if not topic_labels:
1630 return ""
1631 return f"近期直传精读信号:{', '.join(topic_labels)},这些方向会被适度前置。"
1632
1633
1634def format_push_card(
1635 scored_papers: List[PaperWithScore],
1636 profile: Dict = None,
1637 date: str = None,
1638 total_fetched: int = None
1639) -> str:
1640 """Format the daily push card with explicit must-read status and drift hint."""
1641 if date is None:
1642 date = datetime.now().strftime("%m-%d")
1643
1644 must_read = [p for p in scored_papers if p.category == "must_read"]
1645 high_relevant = [p for p in scored_papers if p.category == "high_relevant"]
1646 maybe_interested = [p for p in scored_papers if p.category == "maybe_interested"]
1647 edge_relevant = [p for p in scored_papers if p.category == "edge_relevant"]
1648
1649 total = total_fetched or len(scored_papers)
1650 filtered = len(must_read) + len(high_relevant) + len(maybe_interested) + len(edge_relevant)
1651
1652 lines = [f"📰 今日论文 | {date} | 抓取 {total} 篇 → 筛后 {filtered} 篇", ""]
1653 lines.append(f"━━━ 🔒 必读清单命中({len(must_read)} 篇)━━━")
1654 lines.append(format_must_read_config(profile or {}))
1655 lines.append(format_drift_hint(profile or {}))
1656 reading_signal_hint = format_reading_signal_hint(profile or {})
1657 if reading_signal_hint:
1658 lines.append(reading_signal_hint)
1659
1660 global_count = 0
1661 if must_read:
1662 for paper_with_score in must_read:
1663 global_count += 1
1664 title = str(paper_with_score.paper.get("title", "Unknown") or "Unknown").strip()
1665 authors = paper_with_score.paper.get("authors", [])
1666 categories = paper_with_score.paper.get("categories", [])
1667 category_str = categories[0] if categories else "unknown"
1668 first_author = authors[0].split(",")[0].strip() if isinstance(authors, list) and authors else "Unknown"
1669 lines.append(f"{global_count:02d}. [{category_str}] {first_author} — {title}")
1670 match_reason = format_must_read_reason(paper_with_score.paper, profile or {})
1671 if match_reason:
1672 lines.append(f" 命中:{match_reason}")
1673 else:
1674 must_read_config = (profile or {}).get("must_read", {})
1675 if any(must_read_config.get(key) for key in ("authors", "institutions", "keywords")):

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