@@ -48,14 +48,14 @@ def generate_random_poison_config() -> dict:
4848 """Generate a random poison configuration for testing."""
4949 # Random probability between 0.5 and 1.0
5050 prob = round (random .uniform (0.5 , 1.0 ), 2 )
51-
51+
5252 # Random subset of poison types
5353 num_types = random .randint (1 , len (POISON_TYPES ))
5454 types = random .sample (POISON_TYPES , num_types )
55-
55+
5656 # Random max snippets
5757 max_snippets = random .randint (1 , 3 )
58-
58+
5959 return {
6060 "prob" : prob ,
6161 "types" : types ,
@@ -88,12 +88,12 @@ def run_client(
8888 # Select random or custom cities
8989 origin = custom_origin or random .choice (ORIGINS )
9090 destination = custom_destination or random .choice (DESTINATIONS )
91-
91+
9292 print ("🌍 Travel Planner HTTP Client" )
9393 print ("=" * 60 )
9494 print (f"📍 Origin: { origin } " )
9595 print (f"🎯 Destination: { destination } " )
96-
96+
9797 # Generate poison config if requested
9898 poison_config = None
9999 if use_poison :
@@ -103,75 +103,75 @@ def run_client(
103103 print (f" Types: { ', ' .join (poison_config ['types' ])} " )
104104 print (f" Max snippets: { poison_config ['max' ]} " )
105105 print (f" Seed: { poison_config ['seed' ]} " )
106-
106+
107107 # Generate user request
108108 user_request = generate_travel_request (origin , destination )
109109 print ("\n ✉️ User Request:" )
110110 print (f" { user_request } " )
111-
111+
112112 # Get server URL from environment or default to localhost
113113 server_url = os .getenv ("SERVER_URL" , "http://localhost:8080" )
114-
114+
115115 print ("\n 🔌 Connecting to Flask server..." )
116116 print (f" URL: { server_url } " )
117-
117+
118118 # Prepare request data
119119 data = {
120120 "origin" : origin ,
121121 "destination" : destination ,
122122 "user_request" : user_request ,
123123 "travellers" : random .randint (1 , 4 ),
124124 }
125-
125+
126126 if poison_config :
127127 data ["poison_config" ] = poison_config
128-
128+
129129 print ("\n 📤 Sending request to server..." )
130-
130+
131131 try :
132132 # Make HTTP POST request to /travel/plan endpoint
133133 response = requests .post (
134134 f"{ server_url } /travel/plan" ,
135135 json = data ,
136136 timeout = 300 , # 5 minutes timeout for long-running travel planning
137- headers = {"Content-Type" : "application/json" }
137+ headers = {"Content-Type" : "application/json" },
138138 )
139139 response .raise_for_status ()
140-
140+
141141 result = response .json ()
142-
142+
143143 print ("\n ✅ Received response from server!" )
144144 print ("=" * 60 )
145-
145+
146146 # Display the result
147147 print (f"\n 📋 Session ID: { result ['session_id' ]} " )
148148 print (f"📅 Travel Dates: { result ['departure' ]} → { result ['return_date' ]} " )
149149 print (f"👥 Travellers: { result ['travellers' ]} " )
150-
151- if result .get (' poison_events' ):
150+
151+ if result .get (" poison_events" ):
152152 print ("\n 💉 Poison Events Triggered:" )
153- for event in result [' poison_events' ]:
153+ for event in result [" poison_events" ]:
154154 print (f" - { event } " )
155-
155+
156156 print ("\n ✈️ Flight Summary:" )
157157 print (f" { result ['flight_summary' ]} " )
158-
158+
159159 print ("\n 🏨 Hotel Summary:" )
160160 print (f" { result ['hotel_summary' ]} " )
161-
161+
162162 print ("\n 🎭 Activities Summary:" )
163163 print (f" { result ['activities_summary' ]} " )
164-
164+
165165 print ("\n 🎉 Final Itinerary:" )
166166 print ("─" * 60 )
167- print (result [' final_itinerary' ])
167+ print (result [" final_itinerary" ])
168168 print ("─" * 60 )
169-
170- if result .get (' agent_steps' ):
169+
170+ if result .get (" agent_steps" ):
171171 print ("\n 🤖 Agent Steps:" )
172- for step in result [' agent_steps' ]:
172+ for step in result [" agent_steps" ]:
173173 print (f" - { step ['agent' ]} : { step ['status' ]} " )
174-
174+
175175 except requests .exceptions .Timeout :
176176 print ("\n ❌ Error: Request timed out after 5 minutes" )
177177 sys .exit (1 )
@@ -192,7 +192,7 @@ def run_client(
192192def main ():
193193 """Main entry point for the client."""
194194 import argparse
195-
195+
196196 parser = argparse .ArgumentParser (
197197 description = "Travel Planner MCP Client - Request travel itineraries with optional quality evaluation"
198198 )
@@ -211,9 +211,9 @@ def main():
211211 type = str ,
212212 help = f"Destination city (default: random from { DESTINATIONS } )" ,
213213 )
214-
214+
215215 args = parser .parse_args ()
216-
216+
217217 try :
218218 run_client (
219219 use_poison = not args .no_poison ,
@@ -226,6 +226,7 @@ def main():
226226 except Exception as e :
227227 print (f"\n \n ❌ Error: { e } " )
228228 import traceback
229+
229230 traceback .print_exc ()
230231 sys .exit (1 )
231232
0 commit comments