Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
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 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
gr.
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
# Create and launch the interface
|
38 |
-
|
39 |
-
|
|
|
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()
|