-
Notifications
You must be signed in to change notification settings - Fork 87
/
agents.py
82 lines (70 loc) · 2.71 KB
/
agents.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from crewai import Agent
from textwrap import dedent
from langchain_openai import ChatOpenAI
from tools.search_tools import SearchTools
from tools.calculator_tools import CalculatorTools
"""
Creating Agents Cheat Sheet:
- Think like a boss. Work backwards from the goal and think which employee
you need to hire to get the job done.
- Define the Captain of the crew who orient the other agents towards the goal.
- Define which experts the captain needs to communicate with and delegate tasks to.
Build a top down structure of the crew.
Goal:
- Create a 7-day travel itinerary with detailed per-day plans,
including budget, packing suggestions, and safety tips.
Captain/Manager/Boss:
- Expert Travel Agent
Employees/Experts to hire:
- City Selection Expert
- Local Tour Guide
Notes:
- Agents should be results driven and have a clear goal in mind
- Role is their job title
- Goals should actionable
- Backstory should be their resume
"""
class TravelAgents:
def __init__(self):
self.OpenAIGPT35 = ChatOpenAI(
model_name="gpt-3.5-turbo", temperature=0.7)
self.OpenAIGPT4 = ChatOpenAI(model_name="gpt-4", temperature=0.7)
def expert_travel_agent(self):
return Agent(
role="Expert Travel Agent",
backstory=dedent(
f"""Expert in travel planning and logistics.
I have decades of expereince making travel iteneraries."""),
goal=dedent(f"""
Create a 7-day travel itinerary with detailed per-day plans,
include budget, packing suggestions, and safety tips.
"""),
tools=[
SearchTools.search_internet,
CalculatorTools.calculate
],
verbose=True,
llm=self.OpenAIGPT4,
)
def city_selection_expert(self):
return Agent(
role="City Selection Expert",
backstory=dedent(
f"""Expert at analyzing travel data to pick ideal destinations"""),
goal=dedent(
f"""Select the best cities based on weather, season, prices, and traveler interests"""),
tools=[SearchTools.search_internet],
verbose=True,
llm=self.OpenAIGPT4,
)
def local_tour_guide(self):
return Agent(
role="Local Tour Guide",
backstory=dedent(f"""Knowledgeable local guide with extensive information
about the city, it's attractions and customs"""),
goal=dedent(
f"""Provide the BEST insights about the selected city"""),
tools=[SearchTools.search_internet],
verbose=True,
llm=self.OpenAIGPT4,
)