An AI-powered technical blog writing agent built with LangGraph, LangChain, and Streamlit. The agent can research topics, plan blog content, generate sections, and even create images for blog posts.
- AI-Powered Research: Automatically researches topics using Tavily search
- Smart Planning: Creates detailed blog outlines with tasks, goals, and word targets
- Section Generation: Generates individual blog sections using LLM
- Image Generation: Creates relevant images using Gemini
- Web Interface: User-friendly Streamlit UI for managing the blog writing process
- Export Options: Download blog posts as Markdown or bundled with images
The project consists of two main files:
-
bwa_backend.py: LangGraph-based backend that handles:
- Routing (determines if research is needed)
- Research (fetches relevant information)
- Orchestration (creates blog plan)
- Worker nodes (generate content sections)
- Reducer (merges content and handles images)
-
bwa_frontend.py: Streamlit web interface with:
- Topic input and date selection
- Real-time progress tracking
- Plan, Evidence, Preview, Images, and Logs tabs
- Download functionality
- Clone the repository and navigate to the project directory:
bash
cd AI-blog-agent
- Install the required dependencies:
bash
pip install streamlit langgraph langchain-openai python-dotenv pydantic pandas
- Set up environment variables in a
.envfile:
env
# Required for LLM calls
OPENAI_API_KEY=your_openai_api_key
# Optional - for research functionality
TAVILY_API_KEY=your_tavily_api_key
# Optional - for image generation
GOOGLE_API_KEY=your_google_api_key
- Start the Streamlit application:
bash
streamlit run bwa_frontend.py
-
Open your browser and navigate to
http://localhost:8501 -
Enter a topic in the text area and click "🚀 Generate Blog"
-
View results in the different tabs:
- Plan: Shows the generated blog outline
- Evidence: Displays research findings
- Markdown Preview: Shows the generated blog content
- Images: Displays generated images
- Logs: Shows execution logs
-
Download the blog as Markdown or as a bundle with images
The agent supports three modes:
- closed_book: Evergreen content without research
- hybrid: Evergreen content with some research for up-to-date examples
- open_book: News/roundup content requiring recent research
AI-blog-agent/
├── bwa_backend.py # LangGraph backend
├── bwa_frontend.py # Streamlit frontend
├── README.md # This file
├── 1_bwa_basic.ipynb # Basic blog writing agent notebook
├── 2_bwa_improved_prompting.ipynb # Improved prompting techniques
├── 3_bwa_research.ipynb # Research integration notebook
├── 4_bwa_research_fine_tuned.ipynb # Fine-tuned research workflow
├── 5_bwa_image.ipynb # Image generation capabilities
├── tavily_test.ipynb # Tavily search testing
├── *.md # Generated blog posts
└── images/ # Generated images directory
- Python 3.10+
- OpenAI API key (for LLM)
- Tavily API key (optional, for research)
- Google API key (optional, for image generation)