Abdulla Fahem commited on
Commit
ef0c77d
Β·
1 Parent(s): 9304981

Update application file

Browse files
Files changed (1) hide show
  1. app.py +28 -17
app.py CHANGED
@@ -351,33 +351,38 @@ def format_travel_plan(plan, days):
351
  if line.lower().startswith('day'):
352
  # Save previous day's activities if they exist
353
  if current_day is not None and current_activities:
354
- day_sections.append({
355
- 'day': current_day,
356
- 'activities': current_activities
357
- })
 
 
358
 
359
  # Extract day number
360
  try:
361
  day_part = line.split(':', 1)
362
  day_num = int(''.join(filter(str.isdigit, day_part[0])))
363
- current_day = day_num
364
- current_activities = []
365
-
366
- # Process content after the day header if it exists
367
- if len(day_part) > 1:
368
- # Split activities by periods and filter out empty ones
369
- activities = [act.strip() for act in day_part[1].split('.') if act.strip()]
370
- current_activities.extend(activities)
 
 
371
 
372
  except ValueError:
373
  continue
374
- elif current_day is not None:
 
375
  # Split the line by periods to separate activities
376
  activities = [act.strip() for act in line.split('.') if act.strip()]
377
  current_activities.extend(activities)
378
 
379
- # Add the last day if there are pending activities
380
- if current_day is not None and current_activities:
381
  day_sections.append({
382
  'day': current_day,
383
  'activities': current_activities
@@ -549,7 +554,10 @@ def main():
549
  with col1:
550
  st.metric("Destination", destination)
551
  with col2:
552
- st.metric("Duration", f"{days} days")
 
 
 
553
  with col3:
554
  st.metric("Budget", budget)
555
 
@@ -591,7 +599,10 @@ def main():
591
  with st.container():
592
  st.markdown("### πŸ“ Destination Details")
593
  st.markdown(f"**Location:** {destination}")
594
- st.markdown(f"**Duration:** {days} days")
 
 
 
595
  st.markdown(f"**Budget Level:** {budget}")
596
 
597
  with sum_col2:
 
351
  if line.lower().startswith('day'):
352
  # Save previous day's activities if they exist
353
  if current_day is not None and current_activities:
354
+ # Only add days that are within the requested range
355
+ if current_day <= days:
356
+ day_sections.append({
357
+ 'day': current_day,
358
+ 'activities': current_activities
359
+ })
360
 
361
  # Extract day number
362
  try:
363
  day_part = line.split(':', 1)
364
  day_num = int(''.join(filter(str.isdigit, day_part[0])))
365
+ # Only process days within the requested range
366
+ if day_num <= days:
367
+ current_day = day_num
368
+ current_activities = []
369
+
370
+ # Process content after the day header if it exists
371
+ if len(day_part) > 1:
372
+ # Split activities by periods and filter out empty ones
373
+ activities = [act.strip() for act in day_part[1].split('.') if act.strip()]
374
+ current_activities.extend(activities)
375
 
376
  except ValueError:
377
  continue
378
+ elif current_day is not None and current_day <= days:
379
+ # Only add activities for days within the requested range
380
  # Split the line by periods to separate activities
381
  activities = [act.strip() for act in line.split('.') if act.strip()]
382
  current_activities.extend(activities)
383
 
384
+ # Add the last day if there are pending activities and within range
385
+ if current_day is not None and current_activities and current_day <= days:
386
  day_sections.append({
387
  'day': current_day,
388
  'activities': current_activities
 
554
  with col1:
555
  st.metric("Destination", destination)
556
  with col2:
557
+ if days == 1:
558
+ st.metric("Duration", f"{days} day")
559
+ else:
560
+ st.metric("Duration", f"{days} days")
561
  with col3:
562
  st.metric("Budget", budget)
563
 
 
599
  with st.container():
600
  st.markdown("### πŸ“ Destination Details")
601
  st.markdown(f"**Location:** {destination}")
602
+ if days == 1:
603
+ st.markdown(f"**Duration:** {days} day")
604
+ else:
605
+ st.markdown(f"**Duration:** {days} days")
606
  st.markdown(f"**Budget Level:** {budget}")
607
 
608
  with sum_col2: