-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtools-example.py
More file actions
63 lines (45 loc) · 1.52 KB
/
tools-example.py
File metadata and controls
63 lines (45 loc) · 1.52 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
import os
from crewai import Agent, Task, Crew, Process
from dotenv import load_dotenv
from CalculatorTool import calculate
load_dotenv()
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
os.environ["OPENAI_MODEL_NAME"] = os.getenv("OPENAI_MODEL_NAME")
print("## Welcome to the Math Whiz")
math_input = input("What is your math equation: ")
math_agent = Agent(
role="Math Magician",
goal="You are able to evaluate any math expression",
backstory="YOU ARE A MATH WHIZ.",
verbose=True,
tools=[calculate]
)
writer = Agent(
role="Writer",
goal="Craft compelling explanations based from results of math equations.",
backstory="""You are a renowned Content Strategist, known for your insightful and engaging articles.
You transform complex concepts into compelling narratives.
""",
verbose=True
)
task1 = Task(
description=f"{math_input}",
expected_output="Give full details in bullet points.",
agent=math_agent
)
task2 = Task(
description="""using the insights provided, explain in great detail how the equation and result
were formed.""",
expected_output="""Explain in great detail and save in markdown. Do no add the triple tick marks at the
beginning or end of the file. Also don't say what type it is in the first line.""",
output_file="markdown/math.md",
agent=writer
)
crew = Crew(
agents=[math_agent, writer],
tasks=[task1, task2],
process=Process.sequential,
verbose=2
)
result = crew.kickoff()
print(result)