{"slug": "building-your-own-ai-news-digest-a-developers-tutorial", "title": "Building Your Own AI News Digest: A Developer’s Tutorial", "summary": "A developer built a personalized AI news digest using Python, NewsAPI, and an LLM. The system fetches articles, filters them by relevance, and generates one-sentence summaries for a scannable daily digest. The tutorial covers code for fetching, filtering, and summarizing news, with options for local models to reduce cost.", "body_md": "You’re a developer. You know AI is moving fast—new models, frameworks, papers, and tools drop daily. Trying to keep up by scanning Twitter, Reddit, and a dozen newsletters is a full-time job. What if you could build a **personalized, automated AI news digest** that pulls the stories you actually care about, summarizes them, and delivers them to your inbox or Slack?\n\nIn this tutorial, I’ll show you how to build exactly that using Python, a few free APIs, and an LLM (like GPT or a local model). No fluff, just code and a system you can deploy in an afternoon.\n\nWe’ll use NewsAPI to query for articles with the keyword “AI”. You can also pull from arXiv, Hacker News, or RSS – but the API is the simplest.\n\n``` python\nimport requests\nfrom datetime import datetime, timedelta\n\nNEWS_API_KEY = \"your_key_here\"\n\ndef fetch_ai_news():\n    url = \"https://newsapi.org/v2/everything\"\n    params = {\n        \"q\": \"artificial intelligence OR machine learning OR LLM\",\n        \"from\": (datetime.now() - timedelta(days=1)).strftime(\"%Y-%m-%d\"),\n        \"sortBy\": \"popularity\",\n        \"language\": \"en\",\n        \"pageSize\": 20,\n        \"apiKey\": NEWS_API_KEY\n    }\n    response = requests.get(url, params=params)\n    response.raise_for_status()\n    articles = response.json().get(\"articles\", [])\n    # Deduplicate by title (simple)\n    seen = set()\n    unique = []\n    for art in articles:\n        if art[\"title\"] not in seen:\n            seen.add(art[\"title\"])\n            unique.append(art)\n    return unique\n```\n\n**Output:** a list of dicts with `title`\n\n, `description`\n\n, `url`\n\n, `source`\n\n, and `publishedAt`\n\n.\n\nNot every article is worth your time. Let’s rank them using a simple keyword density check or, better, an embedding similarity to your interests.\n\nFor a lightweight filter, use `functools.lru_cache`\n\nto compute a “relevance score” from the title + description:\n\n```\nKEYWORDS = [\"transformer\", \"GPT\", \"PyTorch\", \"fine-tuning\", \"RAG\", \"diffusion\", \"agent\"]\n\ndef relevance_score(article):\n    text = f\"{article['title']} {article.get('description', '')}\".lower()\n    return sum(1 for kw in KEYWORDS if kw in text)\n\n# Keep only top 10 most relevant\ndef filter_articles(articles, top_k=10):\n    scored = sorted(articles, key=relevance_score, reverse=True)\n    return [a for a in scored if relevance_score(a) > 0][:top_k]\n```\n\n*Pro tip:* For a more sophisticated filter, use `sentence-transformers`\n\nto compare article embeddings with your own interest vector. But that’s a whole separate post – keep it simple first.\n\nNow the fun part. We’ll send each article’s title and description to an LLM and ask for a one‑sentence summary. This makes your digest dense and scannable.\n\n``` python\nimport openai\n\nopenai.api_key = \"sk-...\"\n\ndef summarize_article(article):\n    prompt = f\"\"\"\nSummarize the following AI news article in one clear, factual sentence.\nFocus on the key insight for a developer.\n\nTitle: {article['title']}\nDescription: {article.get('description', '(No description)')}\n\nSummary:\n\"\"\"\n    response = openai.ChatCompletion.create(\n        model=\"gpt-3.5-turbo\",\n        messages=[{\"role\": \"user\", \"content\": prompt}],\n        temperature=0.3,\n        max_tokens=60\n    )\n    return response.choices[0].message.content.strip()\n```\n\n**Why this works:** The LLM condenses the noise into the signal. Even a free model like `gpt-3.5-turbo-0125`\n\ndoes a decent job for under $0.001 per article.\n\n*Warning:* For 10 articles, you’re looking at ~$0.01 per run. Use a local model (e.g., `Phi-3-mini`\n\nvia Ollama) if you want zero cost and total privacy.\n\nI like Markdown – it’s clean, and I can drop it into an email or a GitHub Issue. Here’s a simple template:\n\n``` python\ndef build_digest_md(articles_summaries):\n    lines = [\"# 🤖 AI News Digest\", f\"**{datetime.now().strftime('%A, %B %d, %Y')}**\\n\"]\n    for title, summary, url in articles_summaries:\n        lines.append(f\"- **{title}**\")\n        lines.append(f\"  {summary}\")\n        lines.append(f\"  [[Read more]]({url})\\n\")\n    return \"\\n\".join(lines)\n```\n\n**Example output:**\n\nYou have several options:\n\n`smtplib`\n\nwith Gmail or SendGrid.\nI’ll show a simple email version:\n\n``` python\nimport smtplib\nfrom email.mime.text import MIMEText\n\ndef send_email(subject, body, to_email=\"you@example.com\"):\n    msg = MIMEText(body, \"markdown\")\n    msg[\"Subject\"] = subject\n    msg[\"From\"] = \"digest-bot@example.com\"\n    msg[\"To\"] = to_email\n\n    with smtplib.SMTP(\"smtp.gmail.com\", 587) as server:\n        server.starttls()\n        server.login(\"your_email\", \"app_password\")\n        server.send_message(msg)\n```\n\n(Use an app‑specific password for Gmail; never hardcode secrets – use environment variables.)\n\nCreate `.github/workflows/digest.yml`\n\n:\n\n```\nyaml\nname: Daily AI Digest\non:\n```\n\n", "url": "https://wpnews.pro/news/building-your-own-ai-news-digest-a-developers-tutorial", "canonical_source": "https://dev.to/samchenreviews/building-your-own-ai-news-digest-a-developers-tutorial-agc", "published_at": "2026-06-30 12:01:30+00:00", "updated_at": "2026-06-30 12:19:13.922465+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "developer-tools"], "entities": ["NewsAPI", "OpenAI", "GPT-3.5-turbo", "Phi-3-mini", "Ollama", "Python", "arXiv", "Hacker News"], "alternates": {"html": "https://wpnews.pro/news/building-your-own-ai-news-digest-a-developers-tutorial", "markdown": "https://wpnews.pro/news/building-your-own-ai-news-digest-a-developers-tutorial.md", "text": "https://wpnews.pro/news/building-your-own-ai-news-digest-a-developers-tutorial.txt", "jsonld": "https://wpnews.pro/news/building-your-own-ai-news-digest-a-developers-tutorial.jsonld"}}