Spaces:
Runtime error
Runtime error
fixed indentation
Browse files- __pycache__/Gradio_UI.cpython-313.pyc +0 -0
- app.py +17 -2
- prompts.yaml +0 -1
- tools/__pycache__/final_answer.cpython-313.pyc +0 -0
- tools/__pycache__/find_flight.cpython-313.pyc +0 -0
- tools/__pycache__/mood_to_need.cpython-313.pyc +0 -0
- tools/__pycache__/need_to_destination.cpython-313.pyc +0 -0
- tools/__pycache__/weather_tool.cpython-313.pyc +0 -0
- tools/mock_tools.py +81 -0
__pycache__/Gradio_UI.cpython-313.pyc
ADDED
Binary file (7.7 kB). View file
|
|
app.py
CHANGED
@@ -6,6 +6,7 @@ from tools.find_flight import FlightsFinderTool
|
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
from Gradio_UI import GradioUI
|
8 |
import yaml
|
|
|
9 |
|
10 |
# Initialize Claude model via Hugging Face
|
11 |
model = HfApiModel(
|
@@ -19,14 +20,28 @@ with open("prompts.yaml", "r") as f:
|
|
19 |
prompt_templates = yaml.safe_load(f)
|
20 |
|
21 |
# Define the agent with all tools
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
agent = CodeAgent(
|
23 |
model=model,
|
24 |
tools=[
|
25 |
MoodToNeedTool(), # Step 1: Mood → Need
|
26 |
NeedToDestinationTool(), # Step 2: Need → Destination
|
27 |
WeatherTool(), # Step 3: Weather for destination
|
28 |
-
FlightsFinderTool(), # Step 4: Destination → Flights
|
29 |
-
FinalAnswerTool()
|
30 |
],
|
31 |
max_steps=6,
|
32 |
verbosity_level=1,
|
|
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
from Gradio_UI import GradioUI
|
8 |
import yaml
|
9 |
+
from tool.mock_tools import MoodToNeedTool, NeedToDestinationTool, WeatherTool, FlightsFinderTool, FinalAnswerTool
|
10 |
|
11 |
# Initialize Claude model via Hugging Face
|
12 |
model = HfApiModel(
|
|
|
20 |
prompt_templates = yaml.safe_load(f)
|
21 |
|
22 |
# Define the agent with all tools
|
23 |
+
# agent = CodeAgent(
|
24 |
+
# model=model,
|
25 |
+
# tools=[
|
26 |
+
# MoodToNeedTool(), # Step 1: Mood → Need
|
27 |
+
# NeedToDestinationTool(), # Step 2: Need → Destination
|
28 |
+
# WeatherTool(), # Step 3: Weather for destination
|
29 |
+
# FlightsFinderTool(), # Step 4: Destination → Flights # Step 5: Claude wrap
|
30 |
+
# FinalAnswerTool() # Required final output
|
31 |
+
# ],
|
32 |
+
# max_steps=6,
|
33 |
+
# verbosity_level=1,
|
34 |
+
# prompt_templates=prompt_templates
|
35 |
+
# )
|
36 |
+
|
37 |
agent = CodeAgent(
|
38 |
model=model,
|
39 |
tools=[
|
40 |
MoodToNeedTool(), # Step 1: Mood → Need
|
41 |
NeedToDestinationTool(), # Step 2: Need → Destination
|
42 |
WeatherTool(), # Step 3: Weather for destination
|
43 |
+
FlightsFinderTool(), # Step 4: Destination → Flights
|
44 |
+
FinalAnswerTool() # Step 5: Claude wrap
|
45 |
],
|
46 |
max_steps=6,
|
47 |
verbosity_level=1,
|
prompts.yaml
CHANGED
@@ -67,7 +67,6 @@ planning:
|
|
67 |
8. Call final_answer() with all outputs.
|
68 |
<end_plan>
|
69 |
|
70 |
-
|
71 |
update_facts_pre_messages: |-
|
72 |
### 1. Facts given in the task
|
73 |
### 2. Facts that we have learned
|
|
|
67 |
8. Call final_answer() with all outputs.
|
68 |
<end_plan>
|
69 |
|
|
|
70 |
update_facts_pre_messages: |-
|
71 |
### 1. Facts given in the task
|
72 |
### 2. Facts that we have learned
|
tools/__pycache__/final_answer.cpython-313.pyc
ADDED
Binary file (1.07 kB). View file
|
|
tools/__pycache__/find_flight.cpython-313.pyc
ADDED
Binary file (4.53 kB). View file
|
|
tools/__pycache__/mood_to_need.cpython-313.pyc
ADDED
Binary file (1.88 kB). View file
|
|
tools/__pycache__/need_to_destination.cpython-313.pyc
ADDED
Binary file (3.4 kB). View file
|
|
tools/__pycache__/weather_tool.cpython-313.pyc
ADDED
Binary file (10.4 kB). View file
|
|
tools/mock_tools.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from smolagents.tools import tool
|
2 |
+
|
3 |
+
@tool
|
4 |
+
def mood_to_need(mood: str) -> str:
|
5 |
+
"""
|
6 |
+
Map a mood to a need.
|
7 |
+
|
8 |
+
Args:
|
9 |
+
mood (str): The current emotional state of the user.
|
10 |
+
|
11 |
+
Returns:
|
12 |
+
str: A description of what the user needs based on the mood.
|
13 |
+
"""
|
14 |
+
return "You need relaxation and nature."
|
15 |
+
|
16 |
+
@tool
|
17 |
+
def need_to_destination(need: str) -> str:
|
18 |
+
"""
|
19 |
+
Map a need to a destination.
|
20 |
+
|
21 |
+
Args:
|
22 |
+
need (str): The user's identified need (e.g., relaxation, adventure).
|
23 |
+
|
24 |
+
Returns:
|
25 |
+
str: A suggested destination that fulfills the need.
|
26 |
+
"""
|
27 |
+
return "Bali, Indonesia"
|
28 |
+
|
29 |
+
@tool
|
30 |
+
def get_weather(dest: str) -> str:
|
31 |
+
"""
|
32 |
+
Get weather forecast for a destination.
|
33 |
+
|
34 |
+
Args:
|
35 |
+
dest (str): The destination location.
|
36 |
+
|
37 |
+
Returns:
|
38 |
+
str: A weather forecast for the given destination.
|
39 |
+
"""
|
40 |
+
return "Sunny and 28°C"
|
41 |
+
|
42 |
+
@tool
|
43 |
+
def get_flights(dest: str) -> str:
|
44 |
+
"""
|
45 |
+
Get flight options for a destination.
|
46 |
+
|
47 |
+
Args:
|
48 |
+
dest (str): The destination location.
|
49 |
+
|
50 |
+
Returns:
|
51 |
+
str: A list of flight options for the destination.
|
52 |
+
"""
|
53 |
+
return "Flight from Paris to Bali: €600 roundtrip"
|
54 |
+
|
55 |
+
@tool
|
56 |
+
def final_wrap(info: str) -> str:
|
57 |
+
"""
|
58 |
+
Create a final wrap-up message.
|
59 |
+
|
60 |
+
Args:
|
61 |
+
info (str): Summary information about the destination and travel.
|
62 |
+
|
63 |
+
Returns:
|
64 |
+
str: A personalized wrap-up message.
|
65 |
+
"""
|
66 |
+
return f"Bali sounds like a perfect place for relaxation with great weather and affordable flights!"
|
67 |
+
|
68 |
+
@tool
|
69 |
+
def final_answer_tool(answer: str) -> str:
|
70 |
+
"""
|
71 |
+
Provides a final answer to the user.
|
72 |
+
|
73 |
+
Args:
|
74 |
+
answer (str): The final recommendation or conclusion.
|
75 |
+
|
76 |
+
Returns:
|
77 |
+
str: The same final answer.
|
78 |
+
"""
|
79 |
+
return answer
|
80 |
+
|
81 |
+
|