Spaces:
Running
Running
Adding code to support the expected arival date as an input.
Browse files- app.py +13 -2
- config/agents.yaml +1 -1
- config/tasks.yaml +7 -0
- crew.py +6 -3
- requirements.txt +1 -0
app.py
CHANGED
@@ -11,9 +11,11 @@ A deployment is available at https://huggingface.co/spaces/sambanovasystems/trip
|
|
11 |
|
12 |
import json
|
13 |
import logging
|
|
|
14 |
from typing import List, Tuple
|
15 |
|
16 |
import gradio as gr
|
|
|
17 |
import plotly.graph_objects as go
|
18 |
from crew import AddressSummaryCrew, TravelCrew
|
19 |
|
@@ -46,6 +48,7 @@ def filter_map(text_list: List[str], lat: List[str], lon: List[str]) -> go.Figur
|
|
46 |
def run(
|
47 |
origin: str,
|
48 |
destination: str,
|
|
|
49 |
age: int,
|
50 |
trip_duration: int,
|
51 |
interests: List[str],
|
@@ -59,6 +62,7 @@ def run(
|
|
59 |
Args:
|
60 |
origin: Origin city of the traveller
|
61 |
destination: Destination that traveller is going to
|
|
|
62 |
age: Age profile of traveller
|
63 |
interests: Specific interests of the traveller
|
64 |
cuisine_preferences: Specific cuisine preferences of the traveller
|
@@ -69,12 +73,13 @@ def run(
|
|
69 |
Returns a tuple containing the itinerary and map
|
70 |
"""
|
71 |
logger.info(
|
72 |
-
f'Origin: {origin}, Destination: {destination}, Age: {age}, Duration: {trip_duration},'
|
73 |
f' Interests: {interests}, Cuisines: {cuisine_preferences}, Children: {children}, Daily Budget: {budget}'
|
74 |
)
|
75 |
inputs = {
|
76 |
'origin': origin,
|
77 |
'destination': destination,
|
|
|
78 |
'age': age,
|
79 |
'trip_duration': trip_duration,
|
80 |
'interests': interests,
|
@@ -119,6 +124,7 @@ demo = gr.Interface(
|
|
119 |
inputs=[
|
120 |
gr.Textbox(label='Where are you travelling from?'),
|
121 |
gr.Textbox(label='Where are you going?'),
|
|
|
122 |
gr.Slider(label='Your age?', value=30, minimum=15, maximum=90, step=5),
|
123 |
gr.Slider(label='How many days are you travelling?', value=5, minimum=1, maximum=14, step=1),
|
124 |
gr.CheckboxGroup(
|
@@ -147,7 +153,12 @@ demo = gr.Interface(
|
|
147 |
),
|
148 |
],
|
149 |
outputs=[
|
150 |
-
gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
151 |
gr.Plot(label='Venues on a Map. Please verify with a Navigation System before traveling.'),
|
152 |
],
|
153 |
)
|
|
|
11 |
|
12 |
import json
|
13 |
import logging
|
14 |
+
import datetime
|
15 |
from typing import List, Tuple
|
16 |
|
17 |
import gradio as gr
|
18 |
+
from gradio_calendar import Calendar
|
19 |
import plotly.graph_objects as go
|
20 |
from crew import AddressSummaryCrew, TravelCrew
|
21 |
|
|
|
48 |
def run(
|
49 |
origin: str,
|
50 |
destination: str,
|
51 |
+
arrival_date: datetime,
|
52 |
age: int,
|
53 |
trip_duration: int,
|
54 |
interests: List[str],
|
|
|
62 |
Args:
|
63 |
origin: Origin city of the traveller
|
64 |
destination: Destination that traveller is going to
|
65 |
+
arrival_date: Approximate date when the trip will begin
|
66 |
age: Age profile of traveller
|
67 |
interests: Specific interests of the traveller
|
68 |
cuisine_preferences: Specific cuisine preferences of the traveller
|
|
|
73 |
Returns a tuple containing the itinerary and map
|
74 |
"""
|
75 |
logger.info(
|
76 |
+
f'Origin: {origin}, Destination: {destination}, Arrival Date: {arrival_date}, Age: {age}, Duration: {trip_duration},'
|
77 |
f' Interests: {interests}, Cuisines: {cuisine_preferences}, Children: {children}, Daily Budget: {budget}'
|
78 |
)
|
79 |
inputs = {
|
80 |
'origin': origin,
|
81 |
'destination': destination,
|
82 |
+
'arrival_date': arrival_date.strftime("%m-%d-%Y"),
|
83 |
'age': age,
|
84 |
'trip_duration': trip_duration,
|
85 |
'interests': interests,
|
|
|
124 |
inputs=[
|
125 |
gr.Textbox(label='Where are you travelling from?'),
|
126 |
gr.Textbox(label='Where are you going?'),
|
127 |
+
Calendar(type="datetime", label="Approximate arrival date"),
|
128 |
gr.Slider(label='Your age?', value=30, minimum=15, maximum=90, step=5),
|
129 |
gr.Slider(label='How many days are you travelling?', value=5, minimum=1, maximum=14, step=1),
|
130 |
gr.CheckboxGroup(
|
|
|
153 |
),
|
154 |
],
|
155 |
outputs=[
|
156 |
+
gr.Textbox(
|
157 |
+
label='Complete Personalized Itinerary of your Trip',
|
158 |
+
show_label=True,
|
159 |
+
show_copy_button=True,
|
160 |
+
autoscroll=False,
|
161 |
+
),
|
162 |
gr.Plot(label='Venues on a Map. Please verify with a Navigation System before traveling.'),
|
163 |
],
|
164 |
)
|
config/agents.yaml
CHANGED
@@ -2,7 +2,7 @@ personalized_activity_planner:
|
|
2 |
role: >
|
3 |
Activity Planner
|
4 |
goal: >
|
5 |
-
Research and find cool things to do at the destination, including activities and events that match the traveler's interests and age group. Create detailed notes on the activity or event.
|
6 |
backstory: >
|
7 |
You are skilled at creating personalized itineraries that cater to the specific preferences and demographics of travelers.
|
8 |
|
|
|
2 |
role: >
|
3 |
Activity Planner
|
4 |
goal: >
|
5 |
+
Research and find cool things to do at the destination, including activities and events that match the traveler's interests and age group. Create detailed notes on the activity or event. Pay importance to the planned arrival date of the traveller, which will indicate which will indicate the season.
|
6 |
backstory: >
|
7 |
You are skilled at creating personalized itineraries that cater to the specific preferences and demographics of travelers.
|
8 |
|
config/tasks.yaml
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
personalized_activity_planning_task:
|
2 |
description: >
|
3 |
Research and find cool things to do at {destination}.
|
|
|
|
|
4 |
Focus on activities and events that match the traveler's interests and age group.
|
5 |
Utilize internet search tools and recommendation engines to gather the information.
|
6 |
|
@@ -9,6 +11,8 @@ personalized_activity_planning_task:
|
|
9 |
- origin: {origin}
|
10 |
|
11 |
- destination: {destination}
|
|
|
|
|
12 |
|
13 |
- Approximate age of the adult travelers: {age}
|
14 |
|
@@ -56,6 +60,7 @@ restaurant_scenic_location_scout_task:
|
|
56 |
interest_scout_task:
|
57 |
description: >
|
58 |
Run specifically for the interests of the traveller provided {interests}. As an example if the traveller has interest in museums, plan activities related to museums at the destination.
|
|
|
59 |
Check if children are accompanying in the trip. {children}
|
60 |
If children are accompanying, find activities that might be more appealing to children.
|
61 |
Use internet search tools, review sites, feedback from users, and travel guides.
|
@@ -67,6 +72,8 @@ interest_scout_task:
|
|
67 |
|
68 |
- destination: {destination}
|
69 |
|
|
|
|
|
70 |
- age of the traveler: {age}
|
71 |
|
72 |
- List of interests that the traveller may have: {interests}
|
|
|
1 |
personalized_activity_planning_task:
|
2 |
description: >
|
3 |
Research and find cool things to do at {destination}.
|
4 |
+
Check the arrival_date and schedule activities that are seasonal around the arrival date. As an example, if the arrival data in in winter, and there are ski resorts around the destination, recommend a ski resort.
|
5 |
+
Also map the date to the day of the week and check if the activity you are recommending in open on that day of the week.
|
6 |
Focus on activities and events that match the traveler's interests and age group.
|
7 |
Utilize internet search tools and recommendation engines to gather the information.
|
8 |
|
|
|
11 |
- origin: {origin}
|
12 |
|
13 |
- destination: {destination}
|
14 |
+
|
15 |
+
- Approximate arrival data in month-day-year format: {arrival_date}
|
16 |
|
17 |
- Approximate age of the adult travelers: {age}
|
18 |
|
|
|
60 |
interest_scout_task:
|
61 |
description: >
|
62 |
Run specifically for the interests of the traveller provided {interests}. As an example if the traveller has interest in museums, plan activities related to museums at the destination.
|
63 |
+
Also consider the approximate arrival date, and plan activities specific to the month and the season {arrival_date}
|
64 |
Check if children are accompanying in the trip. {children}
|
65 |
If children are accompanying, find activities that might be more appealing to children.
|
66 |
Use internet search tools, review sites, feedback from users, and travel guides.
|
|
|
72 |
|
73 |
- destination: {destination}
|
74 |
|
75 |
+
- Approximate arrival data in month-day-year format: {arrival_date}
|
76 |
+
|
77 |
- age of the traveler: {age}
|
78 |
|
79 |
- List of interests that the traveller may have: {interests}
|
crew.py
CHANGED
@@ -8,12 +8,16 @@ from crewai_tools import ScrapeWebsiteTool, SerperDevTool
|
|
8 |
# Currently, we use the Llama 3.1 70B model because it seems the most versatile
|
9 |
llm = LLM(model='sambanova/Meta-Llama-3.1-70B-Instruct')
|
10 |
|
|
|
11 |
@CrewBase
|
12 |
class TravelCrew:
|
13 |
"""Crew to do travel planning"""
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
|
18 |
@agent
|
19 |
def personalized_activity_planner(self) -> Agent:
|
@@ -97,7 +101,6 @@ class TravelCrew:
|
|
97 |
"""
|
98 |
return Task(config=self.tasks_config['interest_scout_task'], llm=llm, max_iter=1, agent=self.interest_scout())
|
99 |
|
100 |
-
|
101 |
@task
|
102 |
def restaurant_scenic_location_scout_task(self) -> Task:
|
103 |
"""
|
|
|
8 |
# Currently, we use the Llama 3.1 70B model because it seems the most versatile
|
9 |
llm = LLM(model='sambanova/Meta-Llama-3.1-70B-Instruct')
|
10 |
|
11 |
+
|
12 |
@CrewBase
|
13 |
class TravelCrew:
|
14 |
"""Crew to do travel planning"""
|
15 |
|
16 |
+
def __init__(self) -> None:
|
17 |
+
"""Initialize the crew."""
|
18 |
+
super().__init__()
|
19 |
+
self.agents_config = 'config/agents.yaml'
|
20 |
+
self.tasks_config = 'config/tasks.yaml'
|
21 |
|
22 |
@agent
|
23 |
def personalized_activity_planner(self) -> Agent:
|
|
|
101 |
"""
|
102 |
return Task(config=self.tasks_config['interest_scout_task'], llm=llm, max_iter=1, agent=self.interest_scout())
|
103 |
|
|
|
104 |
@task
|
105 |
def restaurant_scenic_location_scout_task(self) -> Task:
|
106 |
"""
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
crewai
|
2 |
crewai-tools
|
3 |
plotly
|
|
|
|
1 |
crewai
|
2 |
crewai-tools
|
3 |
plotly
|
4 |
+
gradio-calendar
|