A powerful blog generation system using CrewAI with integrated storage capabilities for managing and organizing generated blog posts.
- π€ AI-Powered Blog Generation: Uses CrewAI with multiple agents (researcher, writer, proofreader)
- π Automatic Storage: Automatically saves generated blogs with proper naming and organization
- π Blog Management: List, search, retrieve, and delete stored blogs
- π Storage Statistics: Track storage usage and blog metadata
- π·οΈ Smart Naming: Automatic filename generation based on topic and timestamp
- π Metadata Tracking: Comprehensive metadata for each blog post
- π¨ Workflow Visualization: Visualize agents, tasks, and execution flow
- π Retry System: Configurable retry logic for both tasks and crew execution
# Install the package
pip install -e .
# Or using uv
uv sync# Run the blog writer
$ blog-writerThis will:
- Prompt you for a blog topic
- Generate a comprehensive blog post using AI agents
- Automatically save the blog to the
output/directory - Display the save location
$ blog-writer list$ blog-writer show <blog_id>
# Example: show ai_llms_20241201_143022$ blog-writer search <query>
# Example: search AI$ blog-writer latest$ blog-writer delete <blog_id>
# Example: delete ai_llms_20241201_143022blog-writer statsblog-writer visualizeblog-writer viz workflow # Workflow diagram
blog-writer viz network # Agent network
blog-writer viz timeline # Execution timelineThe visualizations will be saved in the visualizations/ directory:
workflow_diagram.png- Complete workflow showing agents, tasks, and outputsagent_network.png- Network diagram of agent interactionsexecution_timeline.png- Timeline of execution phasesvisualization_summary.json- Metadata about the visualizations
blog-writer
# Uses: 2 crew retries, 5s delay, task-specific retriesblog-writer retry
# Prompts for custom retry settingsThe system creates a blogs/ directory with the following structure:
blogs/
βββ metadata.json # Database of all blogs
βββ ai_llms_20241201_143022/ # Individual blog directory
β βββ draft_blog_post.md # Draft version
β βββ final_blog_post.md # Final version
βββ machine_learning_20241201_150000/
β βββ final_blog_post.md
βββ ...
- Directory:
{sanitized_topic}_{YYYYMMDD_HHMMSS} - Files:
{stage}_blog_post.md(e.g.,draft_blog_post.md,final_blog_post.md)
Each blog entry in metadata.json contains:
{
"topic": "AI and Machine Learning",
"directory": "ai_and_machine_learning_20241201_143022",
"stage": "final",
"filename": "final_blog_post.md",
"created_at": "2024-12-01T14:30:22.123456",
"file_path": "blogs/ai_and_machine_learning_20241201_143022/final_blog_post.md"
}The system provides three types of visualizations:
Shows the complete blog generation process:
- Agents: Researcher, Blog Writer, Proofreader
- Tasks: Research Task, Write Blog Task, Proofread Task
- Outputs: Research Findings, Blog Post (Draft), Final Blog Post
- Flow: Sequential execution with dependencies
Network diagram showing:
- Agent interactions and relationships
- Task dependencies
- Data flow between components
- Visual representation of the crew structure
Timeline showing:
- Execution phases and duration
- Agent responsibilities
- Retry configuration
- Sequential processing flow
from blog_writer.storage import BlogStorage
# Initialize storage
storage = BlogStorage("custom_blogs_dir")
# Save a blog post
file_path = storage.save_blog_post("My Topic", "Blog content...", "final")
# List all blogs
blogs = storage.get_blog_list()
# Retrieve a blog
content = storage.get_blog_content("blog_directory_name")
# Search blogs
results = storage.search_blogs("AI")
# Get latest blog
latest = storage.get_latest_blog()
# Delete a blog
success = storage.delete_blog("blog_directory_name")
# Get storage statistics
stats = storage.get_storage_stats()from blog_writer.visualization import BlogWriterVisualizer
# Create visualizer
visualizer = BlogWriterVisualizer()
# Generate all visualizations
visualizer.generate_all_visualizations("my_visualizations")
# Generate specific visualization
visualizer.create_workflow_diagram("workflow.png")
visualizer.create_agent_network("network.png")
visualizer.create_execution_timeline("timeline.png")You can customize the storage directory:
# In your code
blog_writer = BlogWriter(storage_dir="my_blogs")
# Or for storage only
storage = BlogStorage("my_blogs")Default retry settings:
- Crew Retries: 2 attempts
- Crew Delay: 5 seconds between retries
- Research Task: 2 retries
- Writing Task: 3 retries (most complex)
- Proofreading Task: 2 retries
BLOG_STORAGE_DIR: Default storage directory (defaults to "blogs")
src/blog_writer/
βββ __init__.py
βββ main.py # CLI entry points
βββ crew.py # CrewAI crew definition
βββ storage.py # Storage system
βββ visualization.py # Workflow visualization
βββ cli.py # Command-line interface
βββ config/
β βββ agents.yaml # Agent configurations
β βββ tasks.yaml # Task configurations
- New Storage Methods: Add methods to
BlogStorageclass - New CLI Commands: Add functions to
main.pyand updatecli.py - New Visualizations: Add methods to
BlogWriterVisualizerclass - New Tools: Create tools and integrate with agents
- Permission Errors: Ensure write permissions to the storage directory
- File Not Found: Check if the blog directory exists in the metadata
- Encoding Issues: All files are saved with UTF-8 encoding
- Visualization Errors: Install required packages:
pip install matplotlib networkx
Enable verbose logging by setting the verbose parameter in the CrewAI configuration.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.