A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.
Fix CodeRabbit comments: thread-safety, schema validation, escape markdown, update README
Tiioluwanib1f74931609f
diff --git a/ai_agents/daily-news-digest/README.md b/ai_agents/daily-news-digest/README.mdindex 0d07c04..37f1438 100644--- a/ai_agents/daily-news-digest/README.md+++ b/ai_agents/daily-news-digest/README.md@@ -4,7 +4,7 @@ Automated daily digest from 92 Karpathy-curated tech blogs, delivered to Telegra## How it works-```+```text92 RSS Feeds → Fetch → Filter 24h → MiniMax M2.7 scores → Top 3 articles → Format → Telegram```@@ -28,8 +28,8 @@ Automated daily digest from 92 Karpathy-curated tech blogs, delivered to Telegra**Libraries:**- `feedparser` — RSS feed parsing-- `python-telegram-bot` — Telegram delivery- `python-dotenv` — environment variable management+- `requests` — HTTP requests for RSS feed fetching## Prerequisites@@ -67,7 +67,7 @@ cp .env.example .envOpen `.env` and fill in your credentials:-```+```envMINIMAX_API_KEY=your_minimax_api_key_hereTELEGRAM_BOT_TOKEN=your_telegram_bot_token_hereTELEGRAM_CHAT_ID=your_telegram_chat_id_here@@ -106,12 +106,12 @@ This schedules the digest to run every day at **08:00 UTC**. Adjust the cron exp## Running manually```bash-py skill.py+python skill.py```## Output format-```+```text🗞️ Daily AI Digest — April 1, 2026🔴 BREAKING@@ -129,7 +129,7 @@ Source: Blog Name | [Read more](https://...)## Project structure-```+```textdaily-ai-news-digest/├── skill.py # Main pipeline — fetch, score, format, send├── scripts/diff --git a/ai_agents/daily-news-digest/requirements.txt b/ai_agents/daily-news-digest/requirements.txtindex 5a8c7df..c4af95b 100644--- a/ai_agents/daily-news-digest/requirements.txt+++ b/ai_agents/daily-news-digest/requirements.txt@@ -1,2 +1,3 @@feedparser>=6.0.0python-dotenv>=1.0.0+requests>=2.31.0diff --git a/ai_agents/daily-news-digest/scripts/fetch_rss.py b/ai_agents/daily-news-digest/scripts/fetch_rss.pyindex 603e0cb..25fcb62 100644--- a/ai_agents/daily-news-digest/scripts/fetch_rss.py+++ b/ai_agents/daily-news-digest/scripts/fetch_rss.py@@ -12,6 +12,7 @@ import argparseimport jsonimport sysimport time+import requestsfrom concurrent.futures import ThreadPoolExecutor, as_completedfrom datetime import datetime, timezone, timedeltafrom pathlib import Path@@ -102,14 +103,9 @@ def fetch_feed(source: dict, cutoff: datetime) -> list[dict]:return []try:- # feedparser respects the timeout via socket default — we set it per call- import socket- old_timeout = socket.getdefaulttimeout()- socket.setdefaulttimeout(FETCH_TIMEOUT)- try:- feed = feedparser.parse(url)- finally:- socket.setdefaulttimeout(old_timeout)+ response = requests.get(url, timeout=FETCH_TIMEOUT)+ response.raise_for_status()+ feed = feedparser.parse(response.content)# feedparser doesn't raise on HTTP errors; check bozo flag for malformed feedsif feed.bozo and not feed.entries:diff --git a/ai_agents/daily-news-digest/skill.py b/ai_agents/daily-news-digest/skill.pyindex e08b0c7..05c63b3 100644--- a/ai_agents/daily-news-digest/skill.py+++ b/ai_agents/daily-news-digest/skill.py@@ -136,11 +136,24 @@ if raw_content.startswith("```"):try:llm_result = json.loads(raw_content)selected = llm_result["selected"]+ required_fields = {"title", "summary", "source", "url", "category"}+ for i, article in enumerate(selected):+ missing = required_fields - article.keys()+ if missing:+ print(f"Article {i} missing fields: {missing}", file=sys.stderr)+ sys.exit(1)except (json.JSONDecodeError, KeyError) as e:print(f"Failed to parse LLM response: {e}", file=sys.stderr)sys.exit(1)+def escape_md(text: str) -> str:+ """Escape Markdown special characters for Telegram."""+ for char in ('_', '*', '`', '['):+ text = text.replace(char, '\\' + char)+ return text++# ---------------------------------------------------------------------------# Format the Telegram message# ---------------------------------------------------------------------------@@ -171,8 +184,8 @@ for cat in CATEGORY_ORDER:message_parts.append(f"*{CATEGORY_HEADERS[cat]}*")for art in grouped[cat]:emoji = CATEGORY_EMOJI[cat]- title = art["title"]- summary = art["summary"]+ title = escape_md(art["title"])+ summary = escape_md(art["summary"])source = art["source"]url = art["url"]message_parts.append(