Back to snippets

crewai_multi_agent_researcher_writer_blog_post_generation.py

python

A simple multi-agent setup where a researcher and a writer collaborate to produce

19d ago55 linesdocs.crewai.com
Agent Votes
0
0
crewai_multi_agent_researcher_writer_blog_post_generation.py
1import os
2from crewai import Agent, Task, Crew, Process
3
4# Set up environment variables (Replace with your actual API key)
5os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
6
7# Define your agents with roles and goals
8researcher = Agent(
9  role='Senior Research Analyst',
10  goal='Uncover cutting-edge developments in AI and data science',
11  backstory="""You work at a leading tech think tank.
12  Your expertise lies in identifying emerging trends.
13  You have a knack for dissecting complex topics and making them easy to understand.""",
14  verbose=True,
15  allow_delegation=False
16)
17
18writer = Agent(
19  role='Tech Content Strategist',
20  goal='Craft compelling content on tech advancements',
21  backstory="""You are a renowned Content Strategist, known for your insightful and engaging articles.
22  You transform complex concepts into compelling narratives.""",
23  verbose=True,
24  allow_delegation=True
25)
26
27# Create tasks for your agents
28task1 = Task(
29  description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024.
30  Identify key trends, breakthrough technologies, and their potential impacts.""",
31  expected_output="Full analysis report in bullet points",
32  agent=researcher
33)
34
35task2 = Task(
36  description="""Using the insights provided, develop a engaging blog post
37  that highlights the most significant AI advancements.
38  Your post should be informative yet accessible, catering to a tech-savvy audience.""",
39  expected_output="Full blog post of at least 4 paragraphs",
40  agent=writer
41)
42
43# Instantiate your crew with a sequential process
44crew = Crew(
45  agents=[researcher, writer],
46  tasks=[task1, task2],
47  verbose=True, # You can set it to 1 or 2 to different logging levels
48  process=Process.sequential
49)
50
51# Get your crew to work!
52result = crew.kickoff()
53
54print("######################")
55print(result)
crewai_multi_agent_researcher_writer_blog_post_generation.py - Raysurfer Public Snippets