from swarms import Agent, SequentialWorkflow
import os
# Configure your LLM
api_key = os.getenv("OPENAI_API_KEY")
# Define content creation agents
ideation_agent = Agent(
agent_name="Content-Strategist",
system_prompt="""
You are a content strategist specializing in ideation and planning.
Your role is to:
- Analyze the target topic and audience
- Generate compelling angles and hooks
- Outline key points and structure
- Identify SEO keywords and search intent
- Define success metrics for the content
Create detailed content briefs that writers can execute.
""",
model_name="gpt-4o",
max_loops=1,
dynamic_temperature_enabled=True,
)
writer_agent = Agent(
agent_name="Content-Writer",
system_prompt="""
You are an expert content writer who creates engaging, informative content.
Your role is to:
- Transform content briefs into full drafts
- Write in clear, engaging language
- Incorporate storytelling and examples
- Optimize for readability (short paragraphs, subheadings)
- Include relevant data and citations
Produce draft content that captures attention and provides value.
""",
model_name="gpt-4o",
max_loops=1,
dynamic_temperature_enabled=True,
)
editor_agent = Agent(
agent_name="Content-Editor",
system_prompt="""
You are a professional editor who refines and polishes content.
Your role is to:
- Fix grammar, spelling, and punctuation errors
- Improve sentence structure and flow
- Ensure consistent tone and voice
- Strengthen weak sections and cut fluff
- Verify factual accuracy
Transform good drafts into excellent, polished content.
""",
model_name="gpt-4o",
max_loops=1,
dynamic_temperature_enabled=True,
)
seo_optimizer = Agent(
agent_name="SEO-Specialist",
system_prompt="""
You are an SEO specialist who optimizes content for search engines.
Your role is to:
- Optimize title tags and meta descriptions
- Ensure proper keyword placement and density
- Improve header hierarchy (H1, H2, H3)
- Add internal linking suggestions
- Optimize for featured snippets
Make content rank higher without sacrificing quality.
""",
model_name="gpt-4o",
max_loops=1,
dynamic_temperature_enabled=True,
)
quality_reviewer = Agent(
agent_name="Quality-Reviewer",
system_prompt="""
You are a quality assurance specialist for content.
Your role is to:
- Verify content meets brand guidelines
- Check for plagiarism or duplicate content issues
- Assess overall readability and engagement
- Provide final recommendations
- Approve for publication or request revisions
Ensure only high-quality content reaches publication.
""",
model_name="gpt-4o",
max_loops=1,
dynamic_temperature_enabled=True,
)
# Create the sequential content pipeline
content_pipeline = SequentialWorkflow(
name="Content-Creation-Pipeline",
description="End-to-end content creation from ideation to publication",
agents=[ideation_agent, writer_agent, editor_agent, seo_optimizer, quality_reviewer],
max_loops=1,
)
# Execute content creation
if __name__ == "__main__":
content_request = """
Create a comprehensive blog post on:
Topic: "How to Build AI Agents for Business Automation"
Target Audience: CTOs and technical decision-makers at mid-size companies
Tone: Professional but accessible, focus on practical value
Length: 1500-2000 words
SEO Keywords: AI agents, business automation, intelligent automation
Goal: Generate qualified leads for our AI consulting services
"""
# Run the pipeline
final_content = content_pipeline.run(content_request)
# Save the final content
with open("blog_post_final.md", "w") as f:
f.write(final_content)
print("Content created and saved to blog_post_final.md")