Amitabhab commited on
Commit
99bcc63
·
1 Parent(s): 8663a63

Adding a new museum scout

Browse files

Adding good labels for easy readability
Improving agents and tasks

Files changed (4) hide show
  1. app.py +8 -7
  2. config/agents.yaml +8 -0
  3. config/tasks.yaml +26 -2
  4. crew.py +25 -28
app.py CHANGED
@@ -4,7 +4,7 @@ import json
4
  import gradio as gr
5
  import plotly.graph_objects as go
6
  import logging
7
- from crew import SurpriseTravelCrew, AddressSummaryCrew
8
 
9
  def filter_map(text_list, lat, lon):
10
  fig = go.Figure(go.Scattermapbox(
@@ -43,7 +43,7 @@ def run(origin, destination, age, trip_duration, children, budget):
43
  'children': children,
44
  'budget': budget
45
  }
46
- result = SurpriseTravelCrew().crew().kickoff(inputs=inputs)
47
  inputs_for_address = {
48
  'text': str(result)
49
  }
@@ -73,13 +73,14 @@ demo = gr.Interface(
73
  title="Plan your itinerary with the help of AI",
74
  description="Use this app to create a detailed itinerary on how to explore a new place. Itinerary is customized to your taste. Powered by Sambanova Cloud.",
75
  fn=run,
76
- inputs=["text", "text", gr.Slider(value=30, minimum=15, maximum=90, step=5),
77
- gr.Slider(value=5, minimum=1, maximum=14, step=1),
78
- gr.Checkbox(),
79
- gr.Slider(value=100, minimum=20, maximum=1000, step=20)],
 
80
  outputs=[
81
  gr.Textbox(label="Complete Itinerary", show_copy_button=True, autoscroll=False),
82
- gr.Plot(label="Venues on a Map. Please verify with a Navigation System before going")
83
  ]
84
  )
85
  demo.launch()
 
4
  import gradio as gr
5
  import plotly.graph_objects as go
6
  import logging
7
+ from crew import TravelCrew, AddressSummaryCrew
8
 
9
  def filter_map(text_list, lat, lon):
10
  fig = go.Figure(go.Scattermapbox(
 
43
  'children': children,
44
  'budget': budget
45
  }
46
+ result = TravelCrew().crew().kickoff(inputs=inputs)
47
  inputs_for_address = {
48
  'text': str(result)
49
  }
 
73
  title="Plan your itinerary with the help of AI",
74
  description="Use this app to create a detailed itinerary on how to explore a new place. Itinerary is customized to your taste. Powered by Sambanova Cloud.",
75
  fn=run,
76
+ inputs=[gr.Textbox(label="Origin"), gr.Textbox(label="Destination"),
77
+ gr.Slider(label="Your age?", value=30, minimum=15, maximum=90, step=5),
78
+ gr.Slider(label="How many days are you travelling?", value=5, minimum=1, maximum=14, step=1),
79
+ gr.Checkbox(label="Check if children are travelling with you"),
80
+ gr.Slider(label="Total budget of trip in USD", show_label=True, value=1000, minimum=500, maximum=10000, step=500)],
81
  outputs=[
82
  gr.Textbox(label="Complete Itinerary", show_copy_button=True, autoscroll=False),
83
+ gr.Plot(label="Venues on a Map. Please verify with a Navigation System before traveling.")
84
  ]
85
  )
86
  demo.launch()
config/agents.yaml CHANGED
@@ -14,6 +14,14 @@ restaurant_scout:
14
  backstory: >
15
  As a food lover, you know the best spots in town for a delightful culinary experience. You also have a knack for finding picturesque and entertaining locations.
16
 
 
 
 
 
 
 
 
 
17
  itinerary_compiler:
18
  role: >
19
  Itinerary Compiler
 
14
  backstory: >
15
  As a food lover, you know the best spots in town for a delightful culinary experience. You also have a knack for finding picturesque and entertaining locations.
16
 
17
+ museum_scout:
18
+ role: >
19
+ Museum Scout
20
+ goal: >
21
+ Find well-known as well as off-the-beat museums matching the age profile. Also pay particular attention to if there are children. If children are accompanying, pick up museums which might be more interesting to children.
22
+ backstory: >
23
+ You know the best museums in town for different age groups. Older people may like quieter museums such as art museums. Young children like museums where they can get to touch, feel, and play.
24
+
25
  itinerary_compiler:
26
  role: >
27
  Itinerary Compiler
config/tasks.yaml CHANGED
@@ -16,7 +16,7 @@ personalized_activity_planning_task:
16
 
17
  - how long is the trip: {trip_duration}
18
 
19
- - budget per day in dollars: {budget}
20
  expected_output: >
21
  A list of recommended activities and events for each day of the trip.
22
  Each entry should include the activity name, location including a , a brief description, and why it's suitable for the traveler.
@@ -41,7 +41,31 @@ restaurant_scenic_location_scout_task:
41
 
42
  - how long is the trip: {trip_duration}
43
 
44
- - budget per day in dollars: {budget}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  expected_output: >
46
  A list of recommended restaurants for each day of the trip.
47
  Each entry should include the name, location including a detailed address, type of cuisine or activity, and a brief description and ratings.
 
16
 
17
  - how long is the trip: {trip_duration}
18
 
19
+ - budget for entire trip in dollars: {budget}
20
  expected_output: >
21
  A list of recommended activities and events for each day of the trip.
22
  Each entry should include the activity name, location including a , a brief description, and why it's suitable for the traveler.
 
41
 
42
  - how long is the trip: {trip_duration}
43
 
44
+ - budget for entire trip in dollars: {budget}
45
+ expected_output: >
46
+ A list of recommended restaurants for each day of the trip.
47
+ Each entry should include the name, location including a detailed address, type of cuisine or activity, and a brief description and ratings.
48
+
49
+ museum_scout_task:
50
+ description: >
51
+ Find popular and off-the-beat museums at {destination}. Consider the {age} of the traveller while recommending museums. Check if children are accompanying in the trip. {children}
52
+ If children are accompanying, find museums that might be more appealing to children.
53
+ Use internet search tools, museum review sites, feedback from users, and travel guides.
54
+ Extract the address of the museum so that the same can be displayed to the user.
55
+
56
+ Traveler's information:
57
+
58
+ - origin: {origin}
59
+
60
+ - destination: {destination}
61
+
62
+ - age of the traveler: {age}
63
+
64
+ - Are children accompanying the trip: {children}
65
+
66
+ - how long is the trip: {trip_duration}
67
+
68
+ - budget for entire trip in dollars: {budget}
69
  expected_output: >
70
  A list of recommended restaurants for each day of the trip.
71
  Each entry should include the name, location including a detailed address, type of cuisine or activity, and a brief description and ratings.
crew.py CHANGED
@@ -10,34 +10,13 @@ from crewai_tools import SerperDevTool, ScrapeWebsiteTool
10
  from typing import List, Optional
11
 
12
  import os
13
- llm = LLM(model="sambanova/Meta-Llama-3.1-70B-Instruct")
14
 
15
- """
16
- class Activity(BaseModel):
17
- name: str = Field(..., description="Name of the activity")
18
- location: str = Field(..., description="Location of the activity")
19
- description: str = Field(..., description="Description of the activity")
20
- date: str = Field(..., description="Date of the activity")
21
- cousine: str = Field(..., description="Cousine of the restaurant")
22
- why_its_suitable: str = Field(..., description="Why it's suitable for the traveler")
23
- reviews: Optional[List[str]] = Field(..., description="List of reviews")
24
- rating: Optional[float] = Field(..., description="Rating of the activity")
25
-
26
- class DayPlan(BaseModel):
27
- date: str = Field(..., description="Date of the day")
28
- activities: List[Activity] = Field(..., description="List of activities")
29
- restaurants: List[str] = Field(..., description="List of restaurants")
30
- flight: Optional[str] = Field(None, description="Flight information")
31
-
32
- class Itinerary(BaseModel):
33
- name: str = Field(..., description="Name of the itinerary, something funny")
34
- day_plans: List[DayPlan] = Field(..., description="List of day plans")
35
- hotel: str = Field(..., description="Hotel information")
36
- """
37
 
38
  @CrewBase
39
- class SurpriseTravelCrew():
40
- """SurpriseTravel crew"""
41
  agents_config = 'config/agents.yaml'
42
  tasks_config = 'config/tasks.yaml'
43
 
@@ -61,6 +40,16 @@ class SurpriseTravelCrew():
61
  allow_delegation=False,
62
  )
63
 
 
 
 
 
 
 
 
 
 
 
64
  @agent
65
  def itinerary_compiler(self) -> Agent:
66
  return Agent(
@@ -88,19 +77,27 @@ class SurpriseTravelCrew():
88
  agent=self.restaurant_scout()
89
  )
90
 
 
 
 
 
 
 
 
 
 
91
  @task
92
  def itinerary_compilation_task(self) -> Task:
93
  return Task(
94
  config=self.tasks_config['itinerary_compilation_task'],
95
  llm=llm,
96
  max_iter=1,
97
- agent=self.itinerary_compiler(),
98
- # output_json=Itinerary
99
  )
100
 
101
  @crew
102
  def crew(self) -> Crew:
103
- """Creates the SurpriseTravel crew"""
104
  return Crew(
105
  agents=self.agents, # Automatically created by the @agent decorator
106
  tasks=self.tasks, # Automatically created by the @task decorator
 
10
  from typing import List, Optional
11
 
12
  import os
 
13
 
14
+ # Change the model which you want to use below.
15
+ llm = LLM(model="sambanova/Meta-Llama-3.1-70B-Instruct")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  @CrewBase
18
+ class TravelCrew():
19
+ """Travel crew"""
20
  agents_config = 'config/agents.yaml'
21
  tasks_config = 'config/tasks.yaml'
22
 
 
40
  allow_delegation=False,
41
  )
42
 
43
+ @agent
44
+ def museum_scout(self) -> Agent:
45
+ return Agent(
46
+ config=self.agents_config['museum_scout'],
47
+ llm=llm,
48
+ max_iter=1,
49
+ tools=[SerperDevTool(), ScrapeWebsiteTool()],
50
+ allow_delegation=False,
51
+ )
52
+
53
  @agent
54
  def itinerary_compiler(self) -> Agent:
55
  return Agent(
 
77
  agent=self.restaurant_scout()
78
  )
79
 
80
+ @task
81
+ def museum_scout_task(self) -> Task:
82
+ return Task(
83
+ config=self.tasks_config['museum_scout_task'],
84
+ llm=llm,
85
+ max_iter=1,
86
+ agent=self.museum_scout()
87
+ )
88
+
89
  @task
90
  def itinerary_compilation_task(self) -> Task:
91
  return Task(
92
  config=self.tasks_config['itinerary_compilation_task'],
93
  llm=llm,
94
  max_iter=1,
95
+ agent=self.itinerary_compiler()
 
96
  )
97
 
98
  @crew
99
  def crew(self) -> Crew:
100
+ """Creates the Travel crew"""
101
  return Crew(
102
  agents=self.agents, # Automatically created by the @agent decorator
103
  tasks=self.tasks, # Automatically created by the @task decorator