Marco310 commited on
Commit
cec5bde
·
1 Parent(s): e127d7d

feat: Improved stop point color in visualizer.py

Browse files

feat: Improved logger functionality in the wooden agent tool

app.py CHANGED
@@ -584,7 +584,7 @@ class LifeFlowAI:
584
  def main():
585
  app = LifeFlowAI()
586
  demo = app.build_interface()
587
- demo.launch(server_name="0.0.0.0", server_port=7860, share=True, show_error=True)
588
  #7860
589
  if __name__ == "__main__":
590
  main()
 
584
  def main():
585
  app = LifeFlowAI()
586
  demo = app.build_interface()
587
+ demo.launch(server_name="0.0.0.0", server_port=8080, share=True, show_error=True)
588
  #7860
589
  if __name__ == "__main__":
590
  main()
core/visualizers.py CHANGED
@@ -271,29 +271,44 @@ def create_animated_map(structured_data=None):
271
 
272
  # --- Layer 3: 主要站點 ---
273
  stops_group = folium.FeatureGroup(name="📍 Main travel stops", show=True)
 
 
274
  for i, stop in enumerate(timeline):
275
  coords = stop.get("coordinates", {})
276
  lat, lng = coords.get("lat"), coords.get("lng")
 
277
  if lat and lng:
278
  bounds.append([lat, lng])
279
- if i == 0:
280
- color_code, theme_name = THEMES[0]
281
- elif i == len(timeline) - 1:
282
- color_code, theme_name = THEMES[2]
283
- else:
284
- color_code, theme_name = THEMES[1]
285
 
286
  loc_name = stop.get("location", "")
 
287
  popup_html = create_popup_html(
288
- title=f"STOP {i + 1}", subtitle=loc_name, color=theme_name,
 
 
289
  metrics={
290
  "Arrival time": stop.get("time", ""),
291
  "Weather": stop.get("weather", ""),
292
  "Air quality": stop.get("aqi", {}).get("label", "")
293
  }
294
  )
295
- icon_type = 'flag-checkered' if i == len(timeline) - 1 else ('play' if i == 0 else 'map-marker')
 
 
 
 
 
 
 
 
296
  icon = folium.Icon(color=theme_name, icon=icon_type, prefix='fa')
 
297
  folium.Marker(
298
  location=[lat, lng], icon=icon,
299
  popup=folium.Popup(popup_html, max_width=320),
@@ -313,6 +328,8 @@ def create_animated_map(structured_data=None):
313
  except Exception as e:
314
  logger.error(f"Folium map error: {e}", exc_info=True)
315
  return m._repr_html_()
 
 
316
  return m._repr_html_()
317
 
318
 
 
271
 
272
  # --- Layer 3: 主要站點 ---
273
  stops_group = folium.FeatureGroup(name="📍 Main travel stops", show=True)
274
+ stops_group = folium.FeatureGroup(name="📍 Main travel stops", show=True)
275
+
276
  for i, stop in enumerate(timeline):
277
  coords = stop.get("coordinates", {})
278
  lat, lng = coords.get("lat"), coords.get("lng")
279
+
280
  if lat and lng:
281
  bounds.append([lat, lng])
282
+
283
+ # 🔥🔥🔥 [修正重點] 讓主站點顏色與備用方案同步 🔥🔥🔥
284
+ # 原本邏輯:中間點全部強制為 Blue (THEMES[1])
285
+ # 新邏輯:使用與 Task 相同的餘數循環 (Modulo Cycle)
286
+ theme_idx = i % len(THEMES)
287
+ color_code, theme_name = THEMES[theme_idx]
288
 
289
  loc_name = stop.get("location", "")
290
+
291
  popup_html = create_popup_html(
292
+ title=f"STOP {i + 1}",
293
+ subtitle=loc_name,
294
+ color=theme_name,
295
  metrics={
296
  "Arrival time": stop.get("time", ""),
297
  "Weather": stop.get("weather", ""),
298
  "Air quality": stop.get("aqi", {}).get("label", "")
299
  }
300
  )
301
+
302
+ # 圖示形狀邏輯 (保持不變:起終點特殊,中間點通用)
303
+ if i == 0:
304
+ icon_type = 'play' # 起點
305
+ elif i == len(timeline) - 1:
306
+ icon_type = 'flag-checkered' # 終點
307
+ else:
308
+ icon_type = 'map-marker' # 中間點
309
+
310
  icon = folium.Icon(color=theme_name, icon=icon_type, prefix='fa')
311
+
312
  folium.Marker(
313
  location=[lat, lng], icon=icon,
314
  popup=folium.Popup(popup_html, max_width=320),
 
328
  except Exception as e:
329
  logger.error(f"Folium map error: {e}", exc_info=True)
330
  return m._repr_html_()
331
+
332
+ m.save("tt.html")
333
  return m._repr_html_()
334
 
335
 
src/tools/navigation_toolkit.py CHANGED
@@ -27,7 +27,8 @@ class NavigationToolkit(Toolkit):
27
  session_id = get_session_id()
28
  if session_id:
29
  latest_id = poi_repo.get_last_id_by_session(session_id)
30
- if latest_id and latest_id != optimization_ref_id and latest_id.startswith("optimization"):
 
31
  logger.warning(f"🔄 Auto-Correcting: Switching to latest Session ID: {latest_id}")
32
  data = poi_repo.load(latest_id)
33
 
 
27
  session_id = get_session_id()
28
  if session_id:
29
  latest_id = poi_repo.get_last_id_by_session(session_id)
30
+ logger.warning(f"⚠️ Warning: Checking latest Session ID: {latest_id}")
31
+ if latest_id and latest_id.startswith("optimization"):
32
  logger.warning(f"🔄 Auto-Correcting: Switching to latest Session ID: {latest_id}")
33
  data = poi_repo.load(latest_id)
34
 
src/tools/scout_toolkit.py CHANGED
@@ -15,8 +15,6 @@ class ScoutToolkit(Toolkit):
15
  self.register(self.search_and_offload)
16
 
17
  def _extract_first_json_object(self, text: str) -> str:
18
-
19
-
20
  text = text.strip()
21
 
22
  # 1. 尋找第一個 '{'
 
15
  self.register(self.search_and_offload)
16
 
17
  def _extract_first_json_object(self, text: str) -> str:
 
 
18
  text = text.strip()
19
 
20
  # 1. 尋找第一個 '{'
src/tools/weather_toolkit.py CHANGED
@@ -21,6 +21,7 @@ class WeatherToolkit(Toolkit):
21
  if not data:
22
  logger.warning(f"⚠️ Warning: Ref ID '{nav_ref_id}' not found.")
23
  session_id = get_session_id()
 
24
  if session_id:
25
  latest_id = poi_repo.get_last_id_by_session(session_id)
26
  if latest_id and latest_id != nav_ref_id and latest_id.startswith("navigation"):
 
21
  if not data:
22
  logger.warning(f"⚠️ Warning: Ref ID '{nav_ref_id}' not found.")
23
  session_id = get_session_id()
24
+ logger.warning(f"⚠️ Warning: Checking latest Session ID: {session_id}")
25
  if session_id:
26
  latest_id = poi_repo.get_last_id_by_session(session_id)
27
  if latest_id and latest_id != nav_ref_id and latest_id.startswith("navigation"):