-
Notifications
You must be signed in to change notification settings - Fork 0
/
agents.py
77 lines (66 loc) · 2.65 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
from crewai import Agent
from textwrap import dedent
from langchain_openai import ChatOpenAI
from tools.calculator_tools import CalculatorTools
from tools.search_tools import SearchTools
"""
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 TripAgents:
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",
goal=dedent(f"""
Create a 7-day travel itinerary with detailed per-day plans,
include budget, packing suggestions, and safety tips.
"""),
backstory=dedent(
f"""Expert in travel planning and logistics.
I have decades of expereince making travel iteneraries."""),
tools=[SearchTools.search_internet, CalculatorTools.calculate],
verbose=True,
llm=self.OpenAIGPT35,
)
def city_selection_expert(self):
return Agent(
role="City Selection Expert",
goal=dedent(
f"""Select the best cities based on weather, season, prices, and traveler interests"""),
backstory=dedent(
f"""Expert at analyzing travel data to pick ideal destinations"""),
tools=[SearchTools.search_internet],
verbose=True,
llm=self.OpenAIGPT35,
)
def local_tour_guide(self):
return Agent(
role="Local Tour Guide",
goal=dedent(
f"""Provide the BEST insights about the selected city"""),
backstory=dedent(f"""Knowledgeable local guide with extensive information
about the city, it's attractions and customs"""),
tools=[SearchTools.search_internet],
verbose=True,
llm=self.OpenAIGPT35,
)