Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
#import leafmap
|
3 |
+
import plotly.graph_objects as go
|
4 |
+
|
5 |
+
EXAMPLE_QUERY="Hello"
|
6 |
+
# build the UI in gradio
|
7 |
+
app = gr.Blocks()
|
8 |
+
|
9 |
+
#generic_map = leafmap.Map()
|
10 |
+
|
11 |
+
|
12 |
+
fig = go.Figure(go.Scattermapbox(
|
13 |
+
#customdata=("Kobe"),
|
14 |
+
lat=[34.689999],
|
15 |
+
lon=[135.195557],
|
16 |
+
mode='markers',
|
17 |
+
marker=go.scattermapbox.Marker(
|
18 |
+
size=6
|
19 |
+
),
|
20 |
+
hoverinfo="text",
|
21 |
+
hovertemplate='<b>Name</b>: %{customdata[0]}<br><b>Price</b>: $%{customdata[1]}'
|
22 |
+
))
|
23 |
+
|
24 |
+
fig.update_layout(
|
25 |
+
mapbox_style="open-street-map",
|
26 |
+
hovermode='closest',
|
27 |
+
mapbox=dict(
|
28 |
+
bearing=0,
|
29 |
+
center=go.layout.mapbox.Center(
|
30 |
+
lat=34.68,
|
31 |
+
lon=-135.19
|
32 |
+
),
|
33 |
+
pitch=0,
|
34 |
+
zoom=9
|
35 |
+
),
|
36 |
+
)
|
37 |
+
|
38 |
+
with app:
|
39 |
+
gr.Markdown("## Generate Recommendation")
|
40 |
+
with gr.Tabs():
|
41 |
+
with gr.TabItem("Generate with map"):
|
42 |
+
with gr.Row():
|
43 |
+
with gr.Column():
|
44 |
+
text_input_map = gr.Textbox(
|
45 |
+
EXAMPLE_QUERY, label="Weather query", lines=4
|
46 |
+
)
|
47 |
+
|
48 |
+
radio_map = gr.Radio(
|
49 |
+
value="granite",
|
50 |
+
choices=["granite", "llma"],
|
51 |
+
label="models",
|
52 |
+
)
|
53 |
+
|
54 |
+
query_validation_text = gr.Textbox(
|
55 |
+
label="Query Input", lines=2
|
56 |
+
)
|
57 |
+
# ideally we want to print logs to the app too
|
58 |
+
# logs = gr.Textbox(label="Logs")
|
59 |
+
# app.load(read_logs, None, logs, every=1)
|
60 |
+
with gr.Column():
|
61 |
+
# place where the map will appear
|
62 |
+
gr.Plot(fig),
|
63 |
+
#map,
|
64 |
+
# place where the suggested trip will appear
|
65 |
+
itinerary_output = gr.Textbox(
|
66 |
+
value="Your recommendation will appear here",
|
67 |
+
label="Recommendation suggestion",
|
68 |
+
lines=3,
|
69 |
+
)
|
70 |
+
|
71 |
+
map_button = gr.Button("Generate")
|
72 |
+
# with gr.TabItem("Generate without map"):
|
73 |
+
# with gr.Row():
|
74 |
+
# with gr.Column():
|
75 |
+
# text_input_no_map = gr.Textbox(
|
76 |
+
# value=EXAMPLE_QUERY, label="Travel query", lines=3
|
77 |
+
# )
|
78 |
+
|
79 |
+
# radio_no_map = gr.Radio(
|
80 |
+
# value="gpt-3.5-turbo",
|
81 |
+
# choices=["gpt-3.5-turbo", "gpt-4", "models/text-bison-001"],
|
82 |
+
# label="Model choices",
|
83 |
+
# )
|
84 |
+
|
85 |
+
# query_validation_no_map = gr.Textbox(
|
86 |
+
# label="Query validation information", lines=2
|
87 |
+
# )
|
88 |
+
# with gr.Column():
|
89 |
+
# text_output_no_map = gr.Textbox(
|
90 |
+
# value="Your itinerary will appear here",
|
91 |
+
# label="Itinerary suggestion",
|
92 |
+
# lines=3,
|
93 |
+
# )
|
94 |
+
# text_button = gr.Button("Generate")
|
95 |
+
|
96 |
+
# map_button.click(
|
97 |
+
# generic_map,
|
98 |
+
# inputs=[text_input_map, radio_map],
|
99 |
+
# outputs=[map_output, itinerary_output, query_validation_text],
|
100 |
+
# )
|
101 |
+
# text_button.click(
|
102 |
+
# generic_map,
|
103 |
+
# inputs=[text_input_no_map, radio_no_map],
|
104 |
+
# outputs=[text_output_no_map, query_validation_no_map],
|
105 |
+
# )
|
106 |
+
#app.load(map)
|
107 |
+
|
108 |
+
app.launch()
|