from __future__ import annotations from typing import Any, Dict from news_mcp.config import CLUSTERS_TTL_HOURS, DB_PATH from news_mcp.dedup.cluster import dedup_and_cluster_articles from news_mcp.enrichment.enrich import enrich_cluster from news_mcp.sources.rss_breakingthenews import fetch_breakingthenews_articles from news_mcp.storage.sqlite_store import SQLiteClusterStore def refresh_clusters(topic: str | None = None, limit: int = 80) -> None: store = SQLiteClusterStore(DB_PATH) articles = fetch_breakingthenews_articles(limit=limit) clustered_by_topic = dedup_and_cluster_articles(articles) for t, clusters in clustered_by_topic.items(): if topic and t != topic: continue enriched = [enrich_cluster(c) for c in clusters] store.upsert_clusters(enriched, topic=t)