Corin1998 commited on
Commit
945ebd4
·
verified ·
1 Parent(s): b1c8621

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import os
2
  import json
3
- import time
4
  from typing import List, Dict, Any
5
 
6
  import gradio as gr
@@ -26,20 +25,16 @@ rag_store = RagStore(index_dir=INDEX_DIR)
26
 
27
  # ------------- Handlers -------------
28
 
29
-
30
  def seed_sample_data() -> str:
31
  from sample_data_seed import seed
32
-
33
  n = seed()
34
  return f"Seeded sample data: {n} files."
35
 
36
-
37
  def handle_build_index(progress=gr.Progress(track_tqdm=True)) -> str:
38
  docs = build_corpus(CORPUS_DIRS)
39
  rag_store.build(docs)
40
  return f"Built index with {len(docs)} documents."
41
 
42
-
43
  def handle_generate_plan(
44
  city: str,
45
  hours: float,
@@ -49,20 +44,19 @@ def handle_generate_plan(
49
  pace: str,
50
  date: str,
51
  force_weather: str | None,
 
 
52
  ):
53
  if not rag_store.available():
54
  return None, None, "Index not built yet. Click 'Build/Update RAG Index'."
55
 
56
- # Geocode city -> lat/lon
57
  loc = geocode_city(city)
58
  if not loc:
59
  return None, None, f"Failed to geocode: {city}"
60
  lat, lon = loc["lat"], loc["lon"]
61
 
62
- # Weather summary
63
  weather = get_weather_summary(lat, lon, date=date, override=force_weather or None)
64
 
65
- # Generate plan
66
  plan = generate_plan(
67
  rag=rag_store,
68
  center=(lat, lon),
@@ -73,12 +67,12 @@ def handle_generate_plan(
73
  pace=pace,
74
  weather=weather,
75
  date=date,
 
 
76
  )
77
 
78
- # Map HTML, itinerary table, narrative text
79
  return plan["map_html"], plan["table"], plan["narrative"]
80
 
81
-
82
  with gr.Blocks(css=".small {font-size: 12px}") as demo:
83
  (
84
  city_in,
@@ -89,6 +83,8 @@ with gr.Blocks(css=".small {font-size: 12px}") as demo:
89
  pace_in,
90
  date_in,
91
  weather_in,
 
 
92
  build_btn,
93
  seed_btn,
94
  gen_btn,
@@ -110,6 +106,8 @@ with gr.Blocks(css=".small {font-size: 12px}") as demo:
110
  pace_in,
111
  date_in,
112
  weather_in,
 
 
113
  ],
114
  outputs=[map_out, table_out, text_out],
115
  )
 
1
  import os
2
  import json
 
3
  from typing import List, Dict, Any
4
 
5
  import gradio as gr
 
25
 
26
  # ------------- Handlers -------------
27
 
 
28
  def seed_sample_data() -> str:
29
  from sample_data_seed import seed
 
30
  n = seed()
31
  return f"Seeded sample data: {n} files."
32
 
 
33
  def handle_build_index(progress=gr.Progress(track_tqdm=True)) -> str:
34
  docs = build_corpus(CORPUS_DIRS)
35
  rag_store.build(docs)
36
  return f"Built index with {len(docs)} documents."
37
 
 
38
  def handle_generate_plan(
39
  city: str,
40
  hours: float,
 
44
  pace: str,
45
  date: str,
46
  force_weather: str | None,
47
+ mode_pref: str,
48
+ show_costs: bool,
49
  ):
50
  if not rag_store.available():
51
  return None, None, "Index not built yet. Click 'Build/Update RAG Index'."
52
 
 
53
  loc = geocode_city(city)
54
  if not loc:
55
  return None, None, f"Failed to geocode: {city}"
56
  lat, lon = loc["lat"], loc["lon"]
57
 
 
58
  weather = get_weather_summary(lat, lon, date=date, override=force_weather or None)
59
 
 
60
  plan = generate_plan(
61
  rag=rag_store,
62
  center=(lat, lon),
 
67
  pace=pace,
68
  weather=weather,
69
  date=date,
70
+ mode_pref=mode_pref,
71
+ include_costs=show_costs,
72
  )
73
 
 
74
  return plan["map_html"], plan["table"], plan["narrative"]
75
 
 
76
  with gr.Blocks(css=".small {font-size: 12px}") as demo:
77
  (
78
  city_in,
 
83
  pace_in,
84
  date_in,
85
  weather_in,
86
+ mode_in,
87
+ show_costs_in,
88
  build_btn,
89
  seed_btn,
90
  gen_btn,
 
106
  pace_in,
107
  date_in,
108
  weather_in,
109
+ mode_in,
110
+ show_costs_in,
111
  ],
112
  outputs=[map_out, table_out, text_out],
113
  )