📧 chinmayeepavi@gmail.com Support

Multi-Agent Systems with CrewAI

CrewAI enables teams of specialized agents collaborating on complex tasks:

from crewai import Agent, Task, Crew
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4")

# Define specialized agents
researcher = Agent(
    role="Senior Research Analyst",
    goal="Find and analyze the latest information on the given topic",
    backstory="You are an expert researcher with 20 years of experience "
              "in technology analysis. You excel at finding credible sources "
              "and extracting key insights.",
    llm=llm,
    verbose=True
)

writer = Agent(
    role="Technical Content Writer",
    goal="Write clear, engaging, and technically accurate content",
    backstory="You are a seasoned tech writer who can explain complex "
              "topics in simple terms while maintaining technical accuracy.",
    llm=llm,
    verbose=True
)

editor = Agent(
    role="Senior Editor",
    goal="Ensure content is polished, accurate, and publication-ready",
    backstory="You are a meticulous editor who catches errors, improves "
              "clarity, and ensures consistent tone and style.",
    llm=llm,
    verbose=True
)

# Define tasks
research_task = Task(
    description="Research the current state of AI agents in enterprise "
                "applications. Find real-world examples, market data, "
                "and expert opinions. Focus on 2024-2025 developments.",
    agent=researcher,
    expected_output="A detailed research brief with sources and key findings"
)

writing_task = Task(
    description="Using the research findings, write a 1500-word article "
                "about AI agents in enterprise. Include an introduction, "
                "3-4 main sections with examples, and a conclusion.",
    agent=writer,
    expected_output="A well-structured 1500-word article in markdown format"
)

editing_task = Task(
    description="Review and polish the article. Check for factual accuracy, "
                "improve readability, fix any grammatical issues, and ensure "
                "the article flows well from introduction to conclusion.",
    agent=editor,
    expected_output="A final, publication-ready article"
)

# Create and run the crew
crew = Crew(
    agents=[researcher, writer, editor],
    tasks=[research_task, writing_task, editing_task],
    verbose=True
)

result = crew.kickoff()
print(result)