Spaces:
Running
Running
File size: 4,890 Bytes
64eefbd 488b328 64eefbd 488b328 99bcc63 64eefbd 488b328 64eefbd 488b328 64eefbd 488b328 64eefbd 488b328 64eefbd 488b328 99bcc63 64eefbd 99bcc63 64eefbd c78dd58 64eefbd c78dd58 488b328 64eefbd 488b328 64eefbd 488b328 64eefbd 488b328 64eefbd 488b328 99bcc63 c78dd58 64eefbd c78dd58 64eefbd c78dd58 64eefbd c78dd58 488b328 64eefbd 488b328 64eefbd 488b328 64eefbd 488b328 64eefbd 488b328 1c19586 64eefbd 1c19586 64eefbd 1c19586 64eefbd 1c19586 64eefbd 1c19586 64eefbd 1c19586 64eefbd 1c19586 |
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
"""Implementation based on the Crew AI workflow"""
from crewai import LLM, Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from crewai_tools import ScrapeWebsiteTool, SerperDevTool
# Change the model which you want to use below.
# Currently, we use the Llama 3.1 70B model because it seems the most versatile
llm = LLM(model='sambanova/Meta-Llama-3.1-70B-Instruct')
@CrewBase
class TravelCrew:
"""Crew to do travel planning"""
agents_config = 'config/agents.yaml'
tasks_config = 'config/tasks.yaml'
@agent
def personalized_activity_planner(self) -> Agent:
"""
An agent specialized to build an activity planner
Returns: The agent
"""
return Agent(
config=self.agents_config['personalized_activity_planner'],
llm=llm,
max_iter=1,
tools=[SerperDevTool(), ScrapeWebsiteTool()], # Example of custom tool, loaded at the beginning of file
allow_delegation=False,
)
@agent
def restaurant_scout(self) -> Agent:
"""
An agent specialized to scout for restaurants
Returns: The agent
"""
return Agent(
config=self.agents_config['restaurant_scout'],
llm=llm,
max_iter=1,
tools=[SerperDevTool(), ScrapeWebsiteTool()],
allow_delegation=False,
)
@agent
def interest_scout(self) -> Agent:
"""
An agent specialized to scout for specific interests
Returns: The agent
"""
return Agent(
config=self.agents_config['interest_scout'],
llm=llm,
max_iter=1,
tools=[SerperDevTool(), ScrapeWebsiteTool()],
allow_delegation=False,
)
@agent
def itinerary_compiler(self) -> Agent:
"""
An agent specialized at composing the entire itinirary
Returns: The agent
"""
return Agent(
config=self.agents_config['itinerary_compiler'],
llm=llm,
max_iter=1,
allow_delegation=False,
)
@task
def personalized_activity_planning_task(self) -> Task:
"""
A task that designs and plans for activities.
Returns: A task
"""
return Task(
config=self.tasks_config['personalized_activity_planning_task'],
llm=llm,
max_iter=1,
agent=self.personalized_activity_planner(),
)
@task
def interest_scout_task(self) -> Task:
"""
A task that plans for specific interests of the traveller.
Returns: A task
"""
return Task(config=self.tasks_config['interest_scout_task'], llm=llm, max_iter=1, agent=self.interest_scout())
@task
def restaurant_scenic_location_scout_task(self) -> Task:
"""
A task that picks restaurants.
Returns: A task
"""
return Task(
config=self.tasks_config['restaurant_scenic_location_scout_task'],
llm=llm,
max_iter=1,
agent=self.restaurant_scout(),
)
@task
def itinerary_compilation_task(self) -> Task:
"""
A task that plans for museums.
Returns: A task
"""
return Task(
config=self.tasks_config['itinerary_compilation_task'], llm=llm, max_iter=1, agent=self.itinerary_compiler()
)
@crew
def crew(self) -> Crew:
"""
Creates the Travel Planning crew
Returns: A crew
"""
return Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.sequential,
)
@CrewBase
class AddressSummaryCrew:
"""Address Summary crew"""
agents_config = 'config/address_agents.yaml'
tasks_config = 'config/address_tasks.yaml'
@agent
def address_summarizer(self) -> Agent:
"""
Creates an agent which can summarize addresses in a Json file
Returns: An agent
"""
return Agent(
config=self.agents_config['address_summarizer'],
llm=llm,
max_iter=1,
allow_delegation=False,
)
@task
def address_compilation_task(self) -> Task:
"""
Creates a task which can summarize addresses
Returns: A Task
"""
return Task(
config=self.tasks_config['address_compilation_task'],
llm=llm,
max_iter=1,
agent=self.address_summarizer(),
)
@crew
def crew(self) -> Crew:
"""
Creates the AddressSummary crew
Returns: A Crew
"""
crew = Crew(
agents=self.agents,
tasks=self.tasks,
process=Process.sequential,
)
return crew
|