awacke1 commited on
Commit
2b0ea82
Β·
verified Β·
1 Parent(s): 6bb6281

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -37,12 +37,22 @@ st.set_page_config(
37
 
38
  # [Previous sections like ModelConfig, SFTDataset, ModelBuilder, Utility Functions remain unchanged...]
39
 
40
- # Cargo Travel Time Tool (Now a Proper smolagents Tool)
41
  from smolagents import tool
42
 
43
  @tool
44
  def calculate_cargo_travel_time(origin_coords: Tuple[float, float], destination_coords: Tuple[float, float], cruising_speed_kmh: float = 750.0) -> float:
45
- """Calculate cargo plane travel time between two coordinates."""
 
 
 
 
 
 
 
 
 
 
46
  def to_radians(degrees: float) -> float:
47
  return degrees * (math.pi / 180)
48
  lat1, lon1 = map(to_radians, origin_coords)
@@ -53,8 +63,8 @@ def calculate_cargo_travel_time(origin_coords: Tuple[float, float], destination_
53
  a = (math.sin(dlat / 2) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2) ** 2)
54
  c = 2 * math.asin(math.sqrt(a))
55
  distance = EARTH_RADIUS_KM * c
56
- actual_distance = distance * 1.1
57
- flight_time = (actual_distance / cruising_speed_kmh) + 1.0
58
  return round(flight_time, 2)
59
 
60
  # Main App
@@ -88,7 +98,7 @@ if selected_model != "None" and st.sidebar.button("Load Model πŸ“‚"):
88
  st.session_state['model_loaded'] = True
89
  st.rerun()
90
 
91
- # Main UI with Tabs (only Tab 4 updated here)
92
  tab1, tab2, tab3, tab4 = st.tabs(["Build Tiny Titan 🌱", "Fine-Tune Titan πŸ”§", "Test Titan πŸ§ͺ", "Agentic RAG Party 🌐"])
93
 
94
  # [Tab 1, Tab 2, Tab 3 remain unchanged...]
 
37
 
38
  # [Previous sections like ModelConfig, SFTDataset, ModelBuilder, Utility Functions remain unchanged...]
39
 
40
+ # Cargo Travel Time Tool with Detailed Docstring
41
  from smolagents import tool
42
 
43
  @tool
44
  def calculate_cargo_travel_time(origin_coords: Tuple[float, float], destination_coords: Tuple[float, float], cruising_speed_kmh: float = 750.0) -> float:
45
+ """
46
+ Calculate cargo plane travel time between two coordinates using the great-circle distance.
47
+
48
+ Args:
49
+ origin_coords (Tuple[float, float]): Latitude and longitude of the starting point (e.g., (42.3601, -71.0589)).
50
+ destination_coords (Tuple[float, float]): Latitude and longitude of the destination (e.g., (40.7128, -74.0060)).
51
+ cruising_speed_kmh (float): Speed of the cargo plane in kilometers per hour (default: 750.0).
52
+
53
+ Returns:
54
+ float: Travel time in hours, rounded to two decimal places.
55
+ """
56
  def to_radians(degrees: float) -> float:
57
  return degrees * (math.pi / 180)
58
  lat1, lon1 = map(to_radians, origin_coords)
 
63
  a = (math.sin(dlat / 2) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2) ** 2)
64
  c = 2 * math.asin(math.sqrt(a))
65
  distance = EARTH_RADIUS_KM * c
66
+ actual_distance = distance * 1.1 # 10% buffer for real-world routes
67
+ flight_time = (actual_distance / cruising_speed_kmh) + 1.0 # Add 1 hour for takeoff/landing
68
  return round(flight_time, 2)
69
 
70
  # Main App
 
98
  st.session_state['model_loaded'] = True
99
  st.rerun()
100
 
101
+ # Main UI with Tabs (only Tab 4 shown here for brevity)
102
  tab1, tab2, tab3, tab4 = st.tabs(["Build Tiny Titan 🌱", "Fine-Tune Titan πŸ”§", "Test Titan πŸ§ͺ", "Agentic RAG Party 🌐"])
103
 
104
  # [Tab 1, Tab 2, Tab 3 remain unchanged...]