florentgbelidji HF staff commited on
Commit
1a9f164
·
1 Parent(s): 4217047

Added fixes

Browse files
Files changed (2) hide show
  1. app.py +26 -8
  2. src/gradio_utils.py +2 -5
app.py CHANGED
@@ -71,7 +71,7 @@ def init_default_agent(llm_engine):
71
  tools = get_tools(llm_engine),
72
  model = llm_engine,
73
  additional_authorized_imports=["pandas"],
74
- max_steps=20,
75
  )
76
 
77
  # Initialize the default agent prompt
@@ -101,7 +101,7 @@ def initialize_new_agent(engine_type, api_key):
101
  tools = tools,
102
  model = llm_engine,
103
  additional_authorized_imports=["pandas"],
104
- max_steps=20,
105
  )
106
  return skier_agent, [], gr.Chatbot([], label="Agent Thoughts", type="messages")
107
  except ValueError as e:
@@ -126,14 +126,26 @@ else:
126
 
127
  # Gradio UI
128
  def build_ui():
 
 
 
 
 
 
 
 
 
 
 
 
129
  with gr.Blocks(
130
  theme=gr.themes.Soft(
131
  primary_hue=gr.themes.colors.blue,
132
- secondary_hue=gr.themes.colors.blue)
133
  ) as demo:
134
- gr.Markdown("<center><h1>Ski Touring Agent Planner</h1></center>")
135
 
136
- gr.Image(value="./data/skitourai.jpeg", height=400, width=400)
137
  with gr.Accordion("About the App❓", open=False):
138
  gr.Markdown("""
139
  **🇬🇧 English Version**
@@ -165,6 +177,7 @@ Il est conçu spécifiquement pour aider à planifier des itinéraires de ski de
165
 
166
  Profitez de vos aventures en ski de randonnée en France, mais vérifiez toujours les sources officielles pour votre sécurité !
167
  """, container=True)
 
168
 
169
 
170
  skier_agent = gr.State(lambda: init_default_agent(default_engine))
@@ -195,9 +208,14 @@ Profitez de vos aventures en ski de randonnée en France, mais vérifiez toujour
195
  warning = gr.Warning("The agent can take few seconds to minutes to respond.", visible=True)
196
  text_output = gr.Markdown(value=FINAL_MESSAGE_HEADER, container=True)
197
  warning = gr.Markdown("⚠️ The agent can take few seconds to minutes to respond.", container=True)
198
- text_input = gr.Textbox(lines=1, label="Chat Message", submit_btn=True)
199
- gr.Examples(["Can you provide an itinerary near Grenoble?"], text_input)
200
-
 
 
 
 
 
201
  with gr.Column():
202
  f_map = Folium(value=Map(
203
  location=[45.9237, 6.8694],
 
71
  tools = get_tools(llm_engine),
72
  model = llm_engine,
73
  additional_authorized_imports=["pandas"],
74
+ max_steps=10,
75
  )
76
 
77
  # Initialize the default agent prompt
 
101
  tools = tools,
102
  model = llm_engine,
103
  additional_authorized_imports=["pandas"],
104
+ max_steps=10,
105
  )
106
  return skier_agent, [], gr.Chatbot([], label="Agent Thoughts", type="messages")
107
  except ValueError as e:
 
126
 
127
  # Gradio UI
128
  def build_ui():
129
+
130
+ custom_css = """
131
+ .custom-textbox {
132
+ border: 2px solid #1E90FF; /* DodgerBlue border */
133
+ border-radius: 10px;
134
+ padding: 10px;
135
+ background-color: #b4e2f0; /* Light blue background */
136
+ font-size: 16px; /* Larger font size */
137
+ color: #1E90FF; /* Blue text color */
138
+ }
139
+ """
140
+
141
  with gr.Blocks(
142
  theme=gr.themes.Soft(
143
  primary_hue=gr.themes.colors.blue,
144
+ secondary_hue=gr.themes.colors.blue), css=custom_css
145
  ) as demo:
146
+ gr.Markdown("<center><h1>Ski Touring Agent Planner</h1></center>", )
147
 
148
+ gr.Image(value="./data/skitourai.jpeg", height=300, width=300)
149
  with gr.Accordion("About the App❓", open=False):
150
  gr.Markdown("""
151
  **🇬🇧 English Version**
 
177
 
178
  Profitez de vos aventures en ski de randonnée en France, mais vérifiez toujours les sources officielles pour votre sécurité !
179
  """, container=True)
180
+
181
 
182
 
183
  skier_agent = gr.State(lambda: init_default_agent(default_engine))
 
208
  warning = gr.Warning("The agent can take few seconds to minutes to respond.", visible=True)
209
  text_output = gr.Markdown(value=FINAL_MESSAGE_HEADER, container=True)
210
  warning = gr.Markdown("⚠️ The agent can take few seconds to minutes to respond.", container=True)
211
+ text_input = gr.Textbox(lines=1, label="Chat Message", submit_btn=True, elem_classes=["custom-textbox"])
212
+ with gr.Accordion("🇬🇧 English examples"):
213
+ gr.Examples(["Can you suggest a ski touring itinerary, near Chamonix, of moderate difficulty, with good weather and safe avalanche conditions? ",
214
+ "What are current weather and avalanche conditions in the Vanoise range?"], text_input)
215
+ with gr.Accordion("🇫🇷 Exemples en français", open=False):
216
+ gr.Examples(["Poux-tu suggérer un itinéraire de ski de randonnée, près de Chamonix, d'une difficulté modérée, avec de bonnes conditions météorologiques et un risque avalanche peu élevé?",
217
+ "Quelles sont les conditions météorologiques et le risque avalanche dans le massif de la Vanoise ?"], text_input)
218
+
219
  with gr.Column():
220
  f_map = Folium(value=Map(
221
  location=[45.9237, 6.8694],
src/gradio_utils.py CHANGED
@@ -53,8 +53,8 @@ def create_map_from_markers(dataframe: pd.DataFrame) -> Map:
53
 
54
  Fullscreen(position='topright', title='Expand me', title_cancel='Exit me', force_separate_button=True).add_to(f_map)
55
 
56
- bounds = [[float(row["Latitude"]), float(row["Longitude"])] for _, row in dataframe.iterrows()]
57
- f_map.fit_bounds(bounds, padding=(100, 100))
58
  return f_map
59
 
60
 
@@ -70,7 +70,6 @@ def update_map_on_selection(row: pd.Series, df_routes: gr.State) -> Map:
70
 
71
  f_map = Map(
72
  location=[row["Latitude"][0], row["Longitude"][0]],
73
- zoom_start=10,
74
  tiles=TileLayer(
75
  tiles=MAP_URL,
76
  attr="Google",
@@ -130,10 +129,8 @@ def stream_to_gradio(
130
  final_message = final_answer.get("message")
131
  itineraries = final_answer.get("itineraries")
132
  if itineraries:
133
- print("HEEERE")
134
  df_routes = pd.DataFrame(itineraries)
135
  df_routes.columns = ["id", "Name", "Latitude", "Longitude", "Route Link"]
136
- print(df_routes)
137
 
138
  else:
139
  final_message = final_answer
 
53
 
54
  Fullscreen(position='topright', title='Expand me', title_cancel='Exit me', force_separate_button=True).add_to(f_map)
55
 
56
+ #bounds = [[float(row["Latitude"]), float(row["Longitude"])] for _, row in dataframe.iterrows()]
57
+ #f_map.fit_bounds(bounds, padding=(100, 100))
58
  return f_map
59
 
60
 
 
70
 
71
  f_map = Map(
72
  location=[row["Latitude"][0], row["Longitude"][0]],
 
73
  tiles=TileLayer(
74
  tiles=MAP_URL,
75
  attr="Google",
 
129
  final_message = final_answer.get("message")
130
  itineraries = final_answer.get("itineraries")
131
  if itineraries:
 
132
  df_routes = pd.DataFrame(itineraries)
133
  df_routes.columns = ["id", "Name", "Latitude", "Longitude", "Route Link"]
 
134
 
135
  else:
136
  final_message = final_answer