This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Create and activate virtual environment
python3 -m venv openai-agents-env
source openai-agents-env/bin/activate # macOS/Linux
# openai-agents-env\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Edit .env to add OPENAI_API_KEY# Run the web interface
streamlit run app.py
# Opens browser at http://localhost:8501
# Features:
# - User-friendly interface for API key input
# - Reference blog/RSS feed selection
# - Topic idea generator with keyword and product targeting
# - Google Sheets integration for content tracking
# - Keyword research with Google Trends and Google Ads API
# - Specific reference pages for style analysis
# - Real-time progress tracking
# - Tabbed output (Final Post, Style Guide, Research, SEO Analysis)
# - Download functionality (Markdown, HTML, Word, JSON)# Run the main blog orchestrator directly
python blog_orchestrator.py
# The application will:
# 1. Analyze style from reference blog
# 2. Research the given topic
# 3. Write content matching the style
# 4. Edit and polish the final outputThis is a multi-agent blog content generation system using the OpenAI Agents SDK. The core architecture follows an orchestrated pipeline pattern:
Central coordinator that manages seven specialized agents in a sequential workflow:
- Style Analyzer Agent: Uses WebSearchTool to fetch and analyze content from reference blogs/RSS feeds (or specific pages), extracting writing patterns, tone, structure, and voice characteristics
- Content Checker Agent: Searches for existing content on the topic to ensure uniqueness and suggest differentiation angles
- Research Agent: Conducts web research on the given topic using WebSearchTool to gather facts, statistics, and current information
- Writer Agent: Generates blog content that matches the analyzed style while incorporating research data and product/page targets
- Internal Linker Agent: Adds strategic internal links to relevant pages for SEO optimization
- Editor Agent: Reviews and polishes the content while preserving style characteristics and internal links
- SEO Analyzer Agent: Provides comprehensive SEO performance analysis and optimization recommendations
- All agents use
Runner.run_sync()for synchronous execution - Style Analyzer and Research agents have WebSearchTool for web content access
- Error handling implemented with try/catch blocks around agent operations
- Results passed between agents via dictionary data structure
create_blog_post(): Main workflow method that orchestrates the full pipelineanalyze_blog_style(): Standalone method for extracting style from any blog/RSS feed or specific pagesgenerate_topic_ideas(): AI-powered topic generation with keyword research and duplication checkingextract_blog_topics(): Extract existing topics from RSS feeds for duplication preventioncreate_style_matched_post(): Alias method for backward compatibility
The system passes structured data between agents:
Topic + Reference Blog + Product Target → Style Analysis → Duplication Check → Research → Style-Matched Writing → Internal Linking → Editing → SEO Analysis
Each step produces intermediate results stored in a results dictionary, allowing for debugging and inspection of the pipeline stages.
SheetsManager Class: Manages Google Sheets integration for data persistence
- Stores generated blog posts with metadata (topic, date, reference blog)
- Caches blog topics from RSS feeds to prevent duplicate content generation
- Tracks topic idea usage and keyword research data
- Provides content history and performance analytics
KeywordResearcher Class: Integrates keyword research capabilities
- Google Trends integration via pytrends for trending keywords and related queries
- Google Ads API integration for search volume and competition metrics
- Enriches topic ideas with SEO data (search volume, competition, trend status)
- Provides trend-based estimates when Google Ads API is not configured
OPENAI_API_KEY: Required for OpenAI Agents SDK
OPENAI_ORG_ID: Optional organization ID for billingGOOGLE_ADS_DEVELOPER_TOKEN: For Google Ads API keyword dataGOOGLE_ADS_CLIENT_ID: OAuth2 client ID for Google AdsGOOGLE_ADS_CLIENT_SECRET: OAuth2 client secret for Google AdsGOOGLE_ADS_REFRESH_TOKEN: OAuth2 refresh token for Google AdsGOOGLE_ADS_CUSTOMER_ID: Your Google Ads customer account IDGOOGLE_APPLICATION_CREDENTIALS: Path to Google Sheets service account JSON file (for Sheets integration)
Core dependencies managed in requirements.txt:
openai-agents==0.3.3: OpenAI Agents SDK for multi-agent orchestrationstreamlit==1.50.0: Web interface frameworkpython-dotenv==1.1.1: Environment variable managementgspread==6.2.1: Google Sheets API clientgoogle-auth==2.41.1: Google authentication librarygoogle-ads==28.0.0: Google Ads API for keyword researchpytrends==4.9.2: Google Trends unofficial APIfeedparser==6.0.12: RSS feed parsing for topic extractionbeautifulsoup4==4.14.2: HTML parsing for web contentrequests==2.32.5: HTTP library for web requests
All versions are pinned for reproducibility.