Skip to content

AjayBandiwaddar/BlogCraft-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

AI Blog Writer Agent

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.

Features

  • 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

Architecture

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

Installation

  1. Clone the repository and navigate to the project directory:
bash
cd AI-blog-agent
  1. Install the required dependencies:
bash
pip install streamlit langgraph langchain-openai python-dotenv pydantic pandas
  1. Set up environment variables in a .env file:
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

Usage

  1. Start the Streamlit application:
bash
streamlit run bwa_frontend.py
  1. Open your browser and navigate to http://localhost:8501

  2. Enter a topic in the text area and click "🚀 Generate Blog"

  3. 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
  4. Download the blog as Markdown or as a bundle with images

Blog Generation Modes

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

Project Structure

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

Requirements

  • Python 3.10+
  • OpenAI API key (for LLM)
  • Tavily API key (optional, for research)
  • Google API key (optional, for image generation)

About

AI Blog writer Agent

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors