15
15
tracer = Tracer (api_key = os .getenv ("JUDGMENT_API_KEY" ), project_name = "travel_agent_demo" )
16
16
17
17
18
- @tracer .observe (span_type = "tool" )
18
+ # @tracer.observe(span_type="tool")
19
19
def search_tavily (query ):
20
20
"""Fetch travel data using Tavily API."""
21
21
# API_KEY = os.getenv("TAVILY_API_KEY")
@@ -24,28 +24,28 @@ def search_tavily(query):
24
24
# return results
25
25
return "The weather in Tokyo is sunny with a high of 75°F."
26
26
27
- # @judgment .observe(span_type="tool")
27
+ @ tracer .observe (span_type = "tool" )
28
28
def get_attractions (destination ):
29
29
"""Search for top attractions in the destination."""
30
30
prompt = f"Best tourist attractions in { destination } "
31
31
attractions_search = search_tavily (prompt )
32
32
return attractions_search
33
33
34
- # @judgment .observe(span_type="tool")
34
+ @ tracer .observe (span_type = "tool" )
35
35
def get_hotels (destination ):
36
36
"""Search for hotels in the destination."""
37
37
prompt = f"Best hotels in { destination } "
38
38
hotels_search = search_tavily (prompt )
39
39
return hotels_search
40
40
41
- # @judgment .observe(span_type="tool")
41
+ @ tracer .observe (span_type = "tool" )
42
42
def get_flights (destination ):
43
43
"""Search for flights to the destination."""
44
44
prompt = f"Flights to { destination } from major cities"
45
45
flights_search = search_tavily (prompt )
46
46
return flights_search
47
47
48
- # @judgment .observe(span_type="tool")
48
+ @ tracer .observe (span_type = "tool" )
49
49
def get_weather (destination , start_date , end_date ):
50
50
"""Search for weather information."""
51
51
prompt = f"Weather forecast for { destination } from { start_date } to { end_date } "
@@ -119,27 +119,29 @@ def generate_itinerary(destination, start_date, end_date):
119
119
input = {"destination" : "Paris" , "start_date" : "2025-06-01" , "end_date" : "2025-06-02" },
120
120
expected_tools = [
121
121
{
122
- "tool_name" : "search_tavily " ,
122
+ "tool_name" : "get_attractions " ,
123
123
"parameters" : {
124
- "query " : "Best tourist attractions in Paris"
124
+ "destination " : "Paris"
125
125
}
126
126
},
127
127
{
128
- "tool_name" : "search_tavily " ,
128
+ "tool_name" : "get_hotels " ,
129
129
"parameters" : {
130
- "query " : "Best hotels in Paris"
130
+ "destination " : "Paris"
131
131
}
132
132
},
133
133
{
134
- "tool_name" : "search_tavily " ,
134
+ "tool_name" : "get_flights " ,
135
135
"parameters" : {
136
- "query " : "Flights to Paris from major cities "
136
+ "destination " : "Paris"
137
137
}
138
138
},
139
139
{
140
- "tool_name" : "search_tavily " ,
140
+ "tool_name" : "get_weather " ,
141
141
"parameters" : {
142
- "query" : "Weather forecast for Paris from 2025-06-01 to 2025-06-02"
142
+ "destination" : "Paris" ,
143
+ "start_date" : "2025-06-01" ,
144
+ "end_date" : "2025-06-02"
143
145
}
144
146
}
145
147
]
@@ -156,7 +158,7 @@ def generate_itinerary(destination, start_date, end_date):
156
158
157
159
judgment .assert_test (
158
160
project_name = "travel_agent_demo" ,
159
- examples = [example , example2 ],
161
+ examples = [example ],
160
162
scorers = [ToolOrderScorer (threshold = 0.5 )],
161
163
model = "gpt-4.1-mini" ,
162
164
function = generate_itinerary ,
0 commit comments