Hugo Bui commited on
Commit
0dd2166
Β·
unverified Β·
1 Parent(s): c28dc43
app.py CHANGED
@@ -1,6 +1,6 @@
1
  from smolagents import CodeAgent, LiteLLMModel
2
- from tools.mood_to_need import MoodToNeedTool
3
- from tools.need_to_destination import NeedToDestinationTool
4
  from tools.weather_tool import WeatherTool
5
  from tools.find_flight import FlightsFinderTool
6
  from tools.final_answer import FinalAnswerTool
@@ -19,7 +19,7 @@ model = LiteLLMModel(
19
  )
20
 
21
  # Load prompt templates
22
- with open("prompts.yaml", "r") as f:
23
  prompt_templates = yaml.safe_load(f)
24
 
25
  # Define the agent with all tools
@@ -40,14 +40,14 @@ with open("prompts.yaml", "r") as f:
40
  agent = CodeAgent(
41
  model=model,
42
  tools=[
43
- MoodToNeedTool(model=model), # Step 1: Mood β†’ Need
44
- NeedToDestinationTool(model=model), # Step 2: Need β†’ Destination
45
  WeatherTool(), # Step 3: Weather for destination
46
  FlightsFinderTool(), # Step 4: Destination β†’ Flights # Step 5: Claude wrap
47
  FinalAnswerTool(), # Required final output
48
  CountryInfoTool() # Step 6: Country info
49
  ],
50
- max_steps=6,
51
  verbosity_level=1,
52
  prompt_templates=prompt_templates
53
  )
 
1
  from smolagents import CodeAgent, LiteLLMModel
2
+ from tools.mood_to_need import MoodToNeedTool, claude_mood_to_need_model
3
+ from tools.need_to_destination import NeedToDestinationTool, claude_need_to_destination_model
4
  from tools.weather_tool import WeatherTool
5
  from tools.find_flight import FlightsFinderTool
6
  from tools.final_answer import FinalAnswerTool
 
19
  )
20
 
21
  # Load prompt templates
22
+ with open("prompts_new.yaml", "r") as f:
23
  prompt_templates = yaml.safe_load(f)
24
 
25
  # Define the agent with all tools
 
40
  agent = CodeAgent(
41
  model=model,
42
  tools=[
43
+ MoodToNeedTool(model=claude_mood_to_need_model), # Step 1: Mood β†’ Need
44
+ NeedToDestinationTool(model=claude_need_to_destination_model), # Step 2: Need β†’ Destination
45
  WeatherTool(), # Step 3: Weather for destination
46
  FlightsFinderTool(), # Step 4: Destination β†’ Flights # Step 5: Claude wrap
47
  FinalAnswerTool(), # Required final output
48
  CountryInfoTool() # Step 6: Country info
49
  ],
50
+ max_steps=10,
51
  verbosity_level=1,
52
  prompt_templates=prompt_templates
53
  )
prompts.yaml CHANGED
@@ -53,13 +53,14 @@ system_prompt: |-
53
 
54
 
55
  Your available tools are:
56
- - mood_to_need(mood: str) β†’ str: Extracts the emotional need behind a mood (e.g., "to reconnect").
57
- - need_to_destination(need: str) β†’ dict: Suggests a destination and activity for that need. Returns JSON with keys 'city', 'country', 'activity'.
58
- - weather_forecast(location: str) β†’ str: Gets current weather forecast.
59
- - get_flights(origin: str, destination: str) β†’ str: Lists flights between two cities.
60
- - quote_from_mood(mood: str) β†’ str: Provides a motivational quote based on mood.
61
- - final_wrap(mood, need, destination, activity, weather, flights) β†’ str: Composes final inspirational message.
62
- - final_answer(output: Any): Ends the task and returns the final result.
 
63
 
64
  DO NOT use a tool unless needed. Plan your steps clearly. You can retry with different inputs if the weather is bad.
65
 
@@ -83,14 +84,14 @@ planning:
83
  - Final wrap-up message to user.
84
 
85
  initial_plan: |-
86
- 1. Extract emotional need from user mood using mood_to_need().
87
- 2. Suggest destination and activity using need_to_destination().
88
- 3. Get weather at destination with weather_forecast().
89
- 4. Assess if weather suits the need. If not, return to step 2.
90
- 5. Get flights using get_flights().
91
- 6. Generate quote using quote_from_mood().
92
- 7. Compose final message using final_wrap().
93
- 8. Call final_answer() with all outputs.
94
  <end_plan>
95
 
96
  update_facts_pre_messages: |-
 
53
 
54
 
55
  Your available tools are:
56
+ - MoodToNeed(mood: str) β†’ str: Extracts the emotional need behind a mood (e.g., "to reconnect").
57
+ - NeedToDestination(need: str) β†’ list: Suggests destinations and flight info for that need. Returns list of destinations with flight details.
58
+ - weather_forecast(location: str, date: str, activity_type: str) β†’ str: Gets weather forecast with intelligent recommendations.
59
+ - flights_finder(departure_airport: str, arrival_airport: str, outbound_date: str, return_date: str) β†’ str: Lists flights between airports.
60
+ - country_info(country: str, info_type: str) β†’ str: Gets security, events, holidays and travel info for a country.
61
+ - final_answer(answer: Any): Ends the task and returns the final result.
62
+
63
+ IMPORTANT: You MUST use these tools instead of writing Python code to simulate their functionality. Call the tools directly with their exact names.
64
 
65
  DO NOT use a tool unless needed. Plan your steps clearly. You can retry with different inputs if the weather is bad.
66
 
 
84
  - Final wrap-up message to user.
85
 
86
  initial_plan: |-
87
+ 1. Check if user provided mood, origin, and travel dates. If missing, ask for them.
88
+ 2. Extract emotional need from user mood using MoodToNeed().
89
+ 3. Suggest destinations using NeedToDestination().
90
+ 4. For each suggested destination, get weather forecast using weather_forecast().
91
+ 5. Get country information using country_info() to check safety and context.
92
+ 6. Assess if weather and country conditions suit the need. If not, try another destination.
93
+ 7. Get flights using flights_finder() with proper airport codes.
94
+ 8. Compose final inspirational message and call final_answer().
95
  <end_plan>
96
 
97
  update_facts_pre_messages: |-
prompts_new.yaml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ system_prompt: |-
2
+ You are WanderMind, a world-class travel assistant that helps users find perfect destinations based on their mood.
3
+
4
+ 🎯 YOUR MISSION:
5
+ 1. Get user's mood, origin city/airport, and travel dates
6
+ 2. Use MoodToNeed tool to understand their emotional need
7
+ 3. Use NeedToDestination tool to get destination suggestions
8
+ 4. Use weather_forecast tool to check weather conditions
9
+ 5. Use country_info tool to check safety and context
10
+ 6. Use flights_finder tool to find flights
11
+ 7. Create an inspirational final message with final_answer
12
+
13
+ 🚨 CRITICAL RULES:
14
+ - ALWAYS use the provided tools - NEVER simulate them with Python code
15
+ - Call tools with their exact names: MoodToNeed, NeedToDestination, weather_forecast, flights_finder, country_info, final_answer
16
+ - If user doesn't provide mood, origin, and dates - ask for them first
17
+ - Check multiple destinations if weather/conditions aren't suitable
18
+
19
+ πŸ“‹ WORKFLOW:
20
+ Step 1: Check inputs (mood, origin, travel dates)
21
+ Step 2: need = MoodToNeed(mood="user's mood")
22
+ Step 3: destinations = NeedToDestination(need=need)
23
+ Step 4: For each destination: weather_forecast(location="city, country", date="YYYY-MM-DD")
24
+ Step 5: country_info(country="country name", info_type="security")
25
+ Step 6: flights_finder(departure_airport="XXX", arrival_airport="YYY", outbound_date="YYYY-MM-DD", return_date="YYYY-MM-DD")
26
+ Step 7: final_answer("Complete travel plan with inspiration")
27
+
28
+ πŸ”§ TOOL EXAMPLES:
29
+ ```py
30
+ # Get emotional need
31
+ need = MoodToNeed(mood="stressed and overwhelmed")
32
+
33
+ # Get destinations
34
+ destinations = NeedToDestination(need=need)
35
+
36
+ # Check weather
37
+ weather = weather_forecast(location="Bali, Indonesia", date="2024-07-15", activity_type="beach")
38
+
39
+ # Check country info
40
+ safety = country_info(country="Indonesia", info_type="security")
41
+
42
+ # Find flights
43
+ flights = flights_finder(departure_airport="CDG", arrival_airport="DPS", outbound_date="2024-07-15", return_date="2024-07-22")
44
+
45
+ # Final answer
46
+ final_answer("Your complete travel plan...")
47
+ ```
48
+
49
+ Remember: Use tools, don't simulate them!
50
+
51
+ planning:
52
+ initial_plan: |-
53
+ 1. Verify user provided mood, origin, and travel dates
54
+ 2. Use MoodToNeed(mood) to extract emotional need
55
+ 3. Use NeedToDestination(need) to get destination suggestions
56
+ 4. For each destination: check weather_forecast() and country_info()
57
+ 5. Select best destination based on weather and safety
58
+ 6. Use flights_finder() to get flight options
59
+ 7. Create inspirational message with final_answer()
tools/__pycache__/country_info_tool.cpython-310.pyc CHANGED
Binary files a/tools/__pycache__/country_info_tool.cpython-310.pyc and b/tools/__pycache__/country_info_tool.cpython-310.pyc differ
 
tools/__pycache__/final_answer.cpython-310.pyc ADDED
Binary file (918 Bytes). View file
 
tools/__pycache__/find_flight.cpython-310.pyc ADDED
Binary file (3.58 kB). View file
 
tools/__pycache__/mood_to_need.cpython-310.pyc ADDED
Binary file (2.25 kB). View file
 
tools/__pycache__/need_to_destination.cpython-310.pyc ADDED
Binary file (2.56 kB). View file
 
tools/__pycache__/weather_tool.cpython-310.pyc CHANGED
Binary files a/tools/__pycache__/weather_tool.cpython-310.pyc and b/tools/__pycache__/weather_tool.cpython-310.pyc differ
 
tools/mood_to_need.py CHANGED
@@ -48,7 +48,7 @@ class MoodToNeedTool(Tool):
48
  response = self.model(prompt)
49
  return response.strip()
50
 
51
- client = Anthropic(api_key=os.getenv("ANTHROPIC_KEY"))
52
 
53
  def claude_mood_to_need_model(prompt: str) -> str:
54
  message = client.messages.create(
 
48
  response = self.model(prompt)
49
  return response.strip()
50
 
51
+ client = Anthropic(api_key=os.getenv("ANTROPIC_KEY"))
52
 
53
  def claude_mood_to_need_model(prompt: str) -> str:
54
  message = client.messages.create(
tools/need_to_destination.py CHANGED
@@ -55,7 +55,7 @@ class NeedToDestinationTool(Tool):
55
  return destinations
56
 
57
 
58
- client = Anthropic(api_key=os.getenv("ANTHROPIC_KEY"))
59
 
60
  def claude_need_to_destination_model(prompt: str) -> str:
61
  message = client.messages.create(
 
55
  return destinations
56
 
57
 
58
+ client = Anthropic(api_key=os.getenv("ANTROPIC_KEY"))
59
 
60
  def claude_need_to_destination_model(prompt: str) -> str:
61
  message = client.messages.create(