-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy path6_memory.py
More file actions
60 lines (51 loc) · 1.51 KB
/
6_memory.py
File metadata and controls
60 lines (51 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from dotenv import load_dotenv
load_dotenv()
from crewai import LLM
import os
llm = LLM(
model="gemini/gemini-2.0-flash",
temperature=0.1
)
from crewai import Agent, Task, Crew
from crewai_tools import SerperDevTool
research_agent = Agent(
role="Research Specialist",
goal="Research interesting facts about the topic: {topic}",
backstory="You are an expert at finding relevant and factual data.",
tools=[SerperDevTool()],
verbose=True,
llm=llm
)
writer_agent = Agent(
role="Creative Writer",
goal="Write a short blog summary using the research",
backstory="You are skilled at writing engaging summaries based on provided content.",
llm=llm,
verbose=True,
)
task1 = Task(
description="Find 3-5 interesting and recent facts about {topic} as of year 2025.",
expected_output="A bullet list of 3-5 facts",
agent=research_agent,
)
task2 = Task(
description="Write a 100-word blog post summary about {topic} using the facts from the research.",
expected_output="A blog post summary",
agent=writer_agent,
context=[task1],
)
crew = Crew(
agents=[research_agent, writer_agent],
tasks=[task1, task2],
verbose=True,
memory=True,
embedder={
"provider": "google",
"config": {
"api_key": os.getenv("GEMINI_API_KEY"),
"model": "text-embedding-004"
}
}
)
crew.kickoff(inputs={"topic": "The future of electrical vehicles"})
crew.kickoff(inputs={"topic": "What is the revenue outlook in this sector?"})