Spaces:
Runtime error
Runtime error
Hugo Bui
commited on
test
Browse files- app.py +6 -6
- prompts.yaml +16 -15
- prompts_new.yaml +59 -0
- tools/__pycache__/country_info_tool.cpython-310.pyc +0 -0
- tools/__pycache__/final_answer.cpython-310.pyc +0 -0
- tools/__pycache__/find_flight.cpython-310.pyc +0 -0
- tools/__pycache__/mood_to_need.cpython-310.pyc +0 -0
- tools/__pycache__/need_to_destination.cpython-310.pyc +0 -0
- tools/__pycache__/weather_tool.cpython-310.pyc +0 -0
- tools/mood_to_need.py +1 -1
- tools/need_to_destination.py +1 -1
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("
|
| 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=
|
| 44 |
-
NeedToDestinationTool(model=
|
| 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=
|
| 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 |
-
-
|
| 57 |
-
-
|
| 58 |
-
- weather_forecast(location: str) β str: Gets
|
| 59 |
-
-
|
| 60 |
-
-
|
| 61 |
-
-
|
| 62 |
-
|
|
|
|
| 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.
|
| 87 |
-
2.
|
| 88 |
-
3.
|
| 89 |
-
4.
|
| 90 |
-
5. Get
|
| 91 |
-
6.
|
| 92 |
-
7.
|
| 93 |
-
8.
|
| 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("
|
| 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("
|
| 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(
|