latentspace.

Daily Paper Bot


  • Motivation
    • A bot that automatically fetches the most-upvoted paper each day from HuggingFace Daily Papers, summarizes it in Korean, and posts it to Slack. The entire pipeline — paper fetch → Gemini summary → Slack post → history save — runs daily via a GitHub Actions cron job.

  • Architecture
    • Four modules, each with a single responsibility:

      1. PaperFetcher — queries the HuggingFace API. On weekdays it fetches the day's #1 paper; on weekends it picks the week's top unposted paper.
      2. Summarizer — downloads the full PDF from arXiv and passes it to Gemini 2.5 Flash (chosen because Gemini offers a small free API tier — just enough for one paper a day). Produces a structured Korean summary in five sections: one-liner, problem, method, results, significance.
      3. SlackPoster — formats the summary as Slack Block Kit blocks and sends it via Incoming Webhook. On failure, posts a formatted traceback to the same channel for immediate visibility.
      4. History — stores posted paper IDs in yearly JSON files (posted/2026.json) and auto-generates the repo's README.md papers table.

  • Cron Workflow
    • Cron is a Unix job scheduler that runs commands at fixed times defined by a five-field expression (minute hour day month weekday).
    • GitHub Actions' schedule trigger exposes the same syntax to run workflows on a recurring basis. This bot is set to fire daily at UTC 21:30 (KST 06:30). workflow_dispatch is also enabled for manual runs.
      
          on:
            schedule:
              - cron: '30 21 * * *'  # 06:30 KST daily
            workflow_dispatch:
      

    • After the Python script finishes, the workflow auto-commits and pushes changes to posted/ and README.md. git diff --staged --quiet skips the commit when there are no changes.
      
          - name: Save posted history
            run: |
              git config user.name "github-actions"
              git config user.email "actions@github.com"
              git add posted/ README.md
              git diff --staged --quiet || git commit -m "chore: update posted history"
              git push
      

    • Only two secrets are required: GEMINI_API_KEY and SLACK_WEBHOOK_URL. The workflow uses permissions: contents: write to push directly from the action.

  • Weekday vs. Weekend
    • On weekdays, the fetcher hits /api/daily_papers?date=YYYY-MM-DD and takes the top result, falling back up to 3 previous days if the date is empty.
    • On weekends, it collects all Monday-through-Friday papers, sorts globally by upvote count, and picks the highest unposted one. Papers that were overshadowed by the daily #1 get surfaced in the weekend slot.

  • Ref