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.
- 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.
- Language: Python 3.11+
- Framework: FastAPI
- Orchestration: Inngest
- Search: BrightData (proxies & SERP)
- LLM: OpenAI / OpenRouter
- Dependency Management: uv
-
Clone the repository
git clone <your-repo-url> cd newsletter_agent
-
Install dependencies Using
uv(recommended):uv sync
Or standard pip:
pip install . -
Environment Setup Create a
.envfile in the root directory:BRIGHT_DATA_API_KEY=your_key_here OPENAI_API_KEY=your_key_here
-
Start the Inngest Dev Server
npx inngest-cli@latest dev
-
Start the FastAPI App
uv run uvicorn main:app --reload
The app will be available at
http://127.0.0.1:8000 -
Trigger a Newsletter Generation You can trigger the
newsletter/generateevent via the Inngest dashboard or using the provided script:uv run run.py
├── 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
MIT