MHamdan commited on
Commit
9181a43
·
verified ·
1 Parent(s): 7acb877

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +51 -29
app.py CHANGED
@@ -6,34 +6,56 @@ from smolagents import load_tool
6
  journey_tool = load_tool("MHamdan/journey-metrics-tool", trust_remote_code=True)
7
 
8
  def create_interface():
9
- return gr.Interface(
10
- fn=journey_tool,
11
- inputs=[
12
- gr.Textbox(label="Start Location", placeholder="Enter starting point"),
13
- gr.Textbox(label="Destination Location", placeholder="Enter destination"),
14
- gr.Dropdown(
15
- choices=["driving", "walking", "bicycling", "transit", "plane"],
16
- label="Transportation Mode",
17
- value="driving"
18
- )
19
- ],
20
- outputs=gr.Textbox(label="Journey Details"),
21
- title="Journey Metrics Calculator",
22
- description="Calculate travel distance and time between two locations.",
23
- examples=[
24
- ["Montreal", "Toronto", "plane"],
25
- ["Vancouver", "Whistler", "driving"],
26
- ["Ottawa", "Kingston", "bicycling"],
27
- ["New York", "Los Angeles", "plane"],
28
- ["Sanaa", "Jeddah", "plane"],
29
- ["Sanaa", "Jeddah", "Car"],
30
- ["Sanaa", "Jeddah", "Bus"],
31
- ["Sanaa", "Jeddah", "Bicyle"],
32
- ["Sanaa", "Jeddah", "Walk"],
33
- ["London", "Paris", "train"]
34
- ]
35
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  # Create and launch the interface
38
- iface = create_interface()
39
- iface.launch()
 
6
  journey_tool = load_tool("MHamdan/journey-metrics-tool", trust_remote_code=True)
7
 
8
  def create_interface():
9
+ with gr.Blocks(title="Journey Metrics Calculator") as iface:
10
+ gr.Markdown("# Journey Metrics Calculator")
11
+ gr.Markdown("Calculate travel distance and time between two locations.")
12
+
13
+ with gr.Row():
14
+ with gr.Column():
15
+ start = gr.Textbox(
16
+ label="Start Location",
17
+ placeholder="e.g., Montreal"
18
+ )
19
+ dest = gr.Textbox(
20
+ label="Destination Location",
21
+ placeholder="e.g., Toronto"
22
+ )
23
+ mode = gr.Dropdown(
24
+ choices=["driving", "walking", "bicycling", "transit", "plane"],
25
+ label="Transportation Mode",
26
+ value="driving"
27
+ )
28
+ submit_btn = gr.Button("Calculate Journey")
29
+
30
+ with gr.Column():
31
+ output = gr.Textbox(
32
+ label="Journey Details",
33
+ lines=5
34
+ )
35
+
36
+ # Example data
37
+ gr.Examples(
38
+ examples=[
39
+ ["Montreal", "Toronto", "plane"],
40
+ ["Vancouver", "Whistler", "driving"],
41
+ ["Ottawa", "Kingston", "bicycling"],
42
+ ["New York", "Los Angeles", "plane"],
43
+ ["London", "Paris", "plane"]
44
+ ],
45
+ inputs=[start, dest, mode],
46
+ outputs=output,
47
+ fn=journey_tool,
48
+ cache_examples=True
49
+ )
50
+
51
+ submit_btn.click(
52
+ fn=journey_tool,
53
+ inputs=[start, dest, mode],
54
+ outputs=output
55
+ )
56
+
57
+ return iface
58
 
59
  # Create and launch the interface
60
+ demo = create_interface()
61
+ demo.launch()