Skip to content

An intelligent agent capable of autonomously finding relevant news articles on a given topic and compiling them into a professional, engaging newsletter. (Focus on scalability using inngest)

Notifications You must be signed in to change notification settings

addytrunks/newsletter_agent

Repository files navigation

AI Newsletter Agent 📰

An intelligent agent capable of autonomously finding relevant news articles on a given topic and compiling them into a professional, engaging newsletter.

Built with FastAPI, Inngest, LangChain, and OpenAI.

🚀 Features

  • Automated Web Research: Uses BrightData SERP API to fetch real-time news and "organic" search results.
  • AI Content Generation: Leverages LLMs (via OpenRouter/OpenAI) to synthesize articles into a cohesive newsletter.
  • Resilient Orchestration: Powered by Inngest for retries, step management, and durability.
  • Asynchronous Processing: Fully async implementation for high concurrency.
  • Markdown Export: auto-saves newsletters to local Markdown files.

🛠️ Tech Stack

  • Language: Python 3.11+
  • Framework: FastAPI
  • Orchestration: Inngest
  • Search: BrightData (proxies & SERP)
  • LLM: OpenAI / OpenRouter
  • Dependency Management: uv

📦 Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd newsletter_agent
  2. Install dependencies Using uv (recommended):

    uv sync

    Or standard pip:

    pip install .
  3. Environment Setup Create a .env file in the root directory:

    BRIGHT_DATA_API_KEY=your_key_here
    OPENAI_API_KEY=your_key_here

🏃‍♂️ Running the Agent

  1. Start the Inngest Dev Server

    npx inngest-cli@latest dev
  2. Start the FastAPI App

    uv run uvicorn main:app --reload

    The app will be available at http://127.0.0.1:8000

  3. Trigger a Newsletter Generation You can trigger the newsletter/generate event via the Inngest dashboard or using the provided script:

    uv run run.py

📂 Project Structure

├── main.py                 # FastAPI application and Inngest entry point
├── newsletter_service.py   # Core logic for Search and AI generation
├── custom_types.py         # Pydantic models
├── prompt.py               # Prompt engineering templates
├── run.py                  # Test script to dispatch events
└── newsletters/            # Generated output directory

📝 License

MIT

About

An intelligent agent capable of autonomously finding relevant news articles on a given topic and compiling them into a professional, engaging newsletter. (Focus on scalability using inngest)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages