agarwalamit081 commited on
Commit
0633293
·
verified ·
1 Parent(s): a2227b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +86 -18
app.py CHANGED
@@ -269,7 +269,7 @@ def build_itinerary(destination: str, attractions: str, budget_local: float, day
269
  @tool
270
  def generate_travel_images(destination: str) -> str:
271
  """
272
- Generate two realistic placeholder image URLs for the destination using Picsum Photos API.
273
 
274
  Args:
275
  destination: Destination city name (e.g., "Lisbon")
@@ -277,25 +277,93 @@ def generate_travel_images(destination: str) -> str:
277
  Returns:
278
  JSON-formatted string containing two image URLs with keys "landmark_image" and "street_scene_image"
279
  """
280
- try:
281
- # Use Lorem Picsum for reliable random images with unique seeds
282
- import hashlib
283
- seed1 = int(hashlib.md5(f"{destination}-landmark".encode()).hexdigest()[:8], 16) % 1000
284
- seed2 = int(hashlib.md5(f"{destination}-street".encode()).hexdigest()[:8], 16) % 1000
285
-
286
- landmark_url = f"https://picsum.photos/seed/{seed1}/800/600"
287
- street_url = f"https://picsum.photos/seed/{seed2}/800/600"
288
-
289
- return json.dumps({
290
- "landmark_image": landmark_url,
291
- "street_scene_image": street_url
292
- })
293
- except Exception as e:
294
- # Fallback to generic images
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  return json.dumps({
296
- "landmark_image": "https://picsum.photos/800/600?random=1",
297
- "street_scene_image": "https://picsum.photos/800/600?random=2"
298
  })
 
 
 
 
 
 
 
 
299
 
300
 
301
  @tool
 
269
  @tool
270
  def generate_travel_images(destination: str) -> str:
271
  """
272
+ Generate two travel image URLs using free stock photo services.
273
 
274
  Args:
275
  destination: Destination city name (e.g., "Lisbon")
 
277
  Returns:
278
  JSON-formatted string containing two image URLs with keys "landmark_image" and "street_scene_image"
279
  """
280
+ # Map popular destinations to actual quality travel photos
281
+ # Using Pixabay's CDN which hosts free travel images
282
+ destination_lower = destination.lower().strip()
283
+
284
+ # High-quality travel images for popular destinations
285
+ image_map = {
286
+ "barcelona": {
287
+ "landmark": "https://cdn.pixabay.com/photo/2017/01/31/21/23/architecture-2025080_960_720.jpg",
288
+ "street": "https://cdn.pixabay.com/photo/2016/11/14/04/45/elephant-1822636_960_720.jpg"
289
+ },
290
+ "paris": {
291
+ "landmark": "https://cdn.pixabay.com/photo/2015/10/06/18/26/eiffel-tower-975004_960_720.jpg",
292
+ "street": "https://cdn.pixabay.com/photo/2016/11/18/15/44/paris-1835941_960_720.jpg"
293
+ },
294
+ "london": {
295
+ "landmark": "https://cdn.pixabay.com/photo/2014/11/13/23/34/london-530055_960_720.jpg",
296
+ "street": "https://cdn.pixabay.com/photo/2016/11/29/04/19/bridge-1867744_960_720.jpg"
297
+ },
298
+ "rome": {
299
+ "landmark": "https://cdn.pixabay.com/photo/2016/11/14/05/21/rome-1822559_960_720.jpg",
300
+ "street": "https://cdn.pixabay.com/photo/2016/03/02/20/13/rome-1232437_960_720.jpg"
301
+ },
302
+ "tokyo": {
303
+ "landmark": "https://cdn.pixabay.com/photo/2019/04/20/11/39/japan-4141578_960_720.jpg",
304
+ "street": "https://cdn.pixabay.com/photo/2017/01/28/02/24/japan-2014616_960_720.jpg"
305
+ },
306
+ "new york": {
307
+ "landmark": "https://cdn.pixabay.com/photo/2017/06/07/15/47/new-york-city-2380683_960_720.jpg",
308
+ "street": "https://cdn.pixabay.com/photo/2016/01/19/17/41/statue-of-liberty-1149887_960_720.jpg"
309
+ },
310
+ "amsterdam": {
311
+ "landmark": "https://cdn.pixabay.com/photo/2017/07/31/11/59/canal-2558009_960_720.jpg",
312
+ "street": "https://cdn.pixabay.com/photo/2016/11/29/12/13/architecture-1869547_960_720.jpg"
313
+ },
314
+ "lisbon": {
315
+ "landmark": "https://cdn.pixabay.com/photo/2018/11/29/21/19/hamburg-3846525_960_720.jpg",
316
+ "street": "https://cdn.pixabay.com/photo/2019/08/28/10/37/portugal-4436951_960_720.jpg"
317
+ },
318
+ "berlin": {
319
+ "landmark": "https://cdn.pixabay.com/photo/2016/11/29/03/37/architecture-1867187_960_720.jpg",
320
+ "street": "https://cdn.pixabay.com/photo/2016/02/17/23/03/germany-1206011_960_720.jpg"
321
+ },
322
+ "madrid": {
323
+ "landmark": "https://cdn.pixabay.com/photo/2020/06/15/01/06/architecture-5299558_960_720.jpg",
324
+ "street": "https://cdn.pixabay.com/photo/2019/10/20/09/03/madrid-4563537_960_720.jpg"
325
+ },
326
+ "prague": {
327
+ "landmark": "https://cdn.pixabay.com/photo/2016/11/23/15/32/prague-1853890_960_720.jpg",
328
+ "street": "https://cdn.pixabay.com/photo/2017/09/05/10/19/prague-2717166_960_720.jpg"
329
+ },
330
+ "dubai": {
331
+ "landmark": "https://cdn.pixabay.com/photo/2016/11/22/23/40/burj-khalifa-1851204_960_720.jpg",
332
+ "street": "https://cdn.pixabay.com/photo/2020/02/08/10/37/dubai-4829188_960_720.jpg"
333
+ },
334
+ "singapore": {
335
+ "landmark": "https://cdn.pixabay.com/photo/2016/03/27/21/43/singapore-1284628_960_720.jpg",
336
+ "street": "https://cdn.pixabay.com/photo/2017/12/10/17/40/singapore-3010803_960_720.jpg"
337
+ },
338
+ "istanbul": {
339
+ "landmark": "https://cdn.pixabay.com/photo/2018/04/25/09/14/istanbul-3349451_960_720.jpg",
340
+ "street": "https://cdn.pixabay.com/photo/2020/06/28/14/20/istanbul-5349952_960_720.jpg"
341
+ },
342
+ "athens": {
343
+ "landmark": "https://cdn.pixabay.com/photo/2018/10/30/16/06/water-3784022_960_720.jpg",
344
+ "street": "https://cdn.pixabay.com/photo/2019/09/15/00/10/athens-4477350_960_720.jpg"
345
+ },
346
+ "vienna": {
347
+ "landmark": "https://cdn.pixabay.com/photo/2017/06/28/10/53/schonbrunn-palace-2450019_960_720.jpg",
348
+ "street": "https://cdn.pixabay.com/photo/2018/05/30/00/24/thunderstorm-3440450_960_720.jpg"
349
+ }
350
+ }
351
+
352
+ # Check if we have specific images for this destination
353
+ if destination_lower in image_map:
354
+ images = image_map[destination_lower]
355
  return json.dumps({
356
+ "landmark_image": images["landmark"],
357
+ "street_scene_image": images["street"]
358
  })
359
+
360
+ # Generic high-quality travel images as fallback
361
+ return json.dumps({
362
+ "landmark_image": "https://cdn.pixabay.com/photo/2016/11/29/12/13/architecture-1869547_960_720.jpg",
363
+ "street_scene_image": "https://cdn.pixabay.com/photo/2016/11/22/19/15/hand-1850120_960_720.jpg"
364
+ })
365
+
366
+
367
 
368
 
369
  @tool