Skip to content

Commit e912a02

Browse files
committed
Agent working
1 parent f87bfec commit e912a02

File tree

2 files changed

+83
-13
lines changed

2 files changed

+83
-13
lines changed

agents.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from crewai import Crew, Task, Agent, Process
2+
from crewai_tools import SerperDevTool
3+
from langchain_google_genai import ChatGoogleGenerativeAI
4+
import os
5+
6+
os.environ["GOOGLE_API_KEY"] = "AIzaSyAdvi5FDIVPLUokRD4KBjve4UdfZOSmbVo"
7+
os.environ["SERPER_API_KEY"] = "29e9856df645a3ac5c5bcb6bdad3e582be0322fa"
8+
9+
10+
11+
# Create the first LLM
12+
13+
messages = [
14+
(
15+
"system",
16+
"You are a helpful assistant that translates English to French. Translate the user sentence.",
17+
),
18+
("human", "I love programming."),
19+
]
20+
21+
llm = ChatGoogleGenerativeAI(
22+
model="gemini-1.5-pro",
23+
temperature=0,
24+
max_tokens=None,
25+
timeout=None,
26+
max_retries=2
27+
)
28+
29+
search_tool = SerperDevTool()
30+
31+
# Define your agents with roles and goals
32+
researcher = Agent(
33+
role='Senior Research Analyst',
34+
goal='Uncover cutting-edge developments in AI and data science',
35+
backstory="""You work at a leading tech think tank.
36+
Your expertise lies in identifying emerging trends.
37+
You have a knack for dissecting complex data and presenting actionable insights.""",
38+
verbose=True,
39+
llm=llm,
40+
allow_delegation=False,
41+
tools=[search_tool]
42+
)
43+
writer = Agent(
44+
role='Tech Content Strategist',
45+
goal='Craft compelling content on tech advancements',
46+
backstory="""You are a renowned Content Strategist, known for your insightful and engaging articles.
47+
You transform complex concepts into compelling narratives.""",
48+
verbose=True,
49+
llm=llm,
50+
allow_delegation=False
51+
)
52+
53+
# Create tasks for your agents
54+
task1 = Task(
55+
description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024.
56+
Identify key trends, breakthrough technologies, and potential industry impacts.""",
57+
expected_output="Full analysis report in bullet points",
58+
output_file="task1output.txt",
59+
agent=researcher
60+
)
61+
62+
task2 = Task(
63+
description="""Using the insights provided, develop an engaging blog
64+
post that highlights the most significant AI advancements.
65+
Your post should be informative yet accessible, catering to a tech-savvy audience.
66+
Make it sound cool, avoid complex words so it doesn't sound like AI.""",
67+
expected_output="Full blog post of at least 4 paragraphs",
68+
agent=writer
69+
)
70+
71+
# Instantiate your crew with a sequential process
72+
crew = Crew(
73+
agents=[researcher, writer],
74+
tasks=[task1, task2],
75+
verbose=True,
76+
process = Process.sequential
77+
)
78+
79+
# Get your crew to work!
80+
result = crew.kickoff()
81+
82+
print("######################")
83+
print(result)

roles.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)