File size: 3,533 Bytes
e9383a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3657f9a
 
 
e9383a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import gradio as gr
#import leafmap
import plotly.graph_objects as go

EXAMPLE_QUERY="Hello"
 # build the UI in gradio
app = gr.Blocks()

#generic_map = leafmap.Map()


fig = go.Figure(go.Scattermapbox(
            #customdata=("Kobe"),
            lat=[34.689999],
            lon=[135.195557],
            mode='markers',
            marker=go.scattermapbox.Marker(
                size=6
            ),
            hoverinfo="text",
            hovertemplate='<b>Name</b>: %{customdata[0]}<br><b>Price</b>: $%{customdata[1]}'
        ))

fig.update_layout(
    mapbox_style="open-street-map",
    hovermode='closest',
    mapbox=dict(
        bearing=0,
        center=go.layout.mapbox.Center(
            lat=34.68,
            lon=-135.19
        ),
        pitch=0,
        zoom=9
    ),
)

with app:
    gr.Markdown("## Generate Recommendation")
    with gr.Tabs():
        with gr.TabItem("Generate with map"):
            with gr.Row():
                with gr.Column():
                    text_input_map = gr.Textbox(
                        EXAMPLE_QUERY, label="Weather query", lines=4
                    )

                    radio_map = gr.Radio(
                        value="Kobe",
                        choices=["Kobe", "Tokyo"],
                        label="Location",
                    )

                    query_validation_text = gr.Textbox(
                        label="Query Input", lines=2
                    )
                    # ideally we want to print logs to the app too
                    # logs = gr.Textbox(label="Logs")
                    # app.load(read_logs, None, logs, every=1)
                with gr.Column():
                    # place where the map will appear
                    gr.Plot(fig),
                    #map,
                    # place where the suggested trip will appear
                    itinerary_output = gr.Textbox(
                        value="Your recommendation will appear here",
                        label="Recommendation suggestion",
                        lines=3,
                    )
                
            map_button = gr.Button("Generate")
        # with gr.TabItem("Generate without map"):
        #     with gr.Row():
        #         with gr.Column():
        #             text_input_no_map = gr.Textbox(
        #                 value=EXAMPLE_QUERY, label="Travel query", lines=3
        #             )

        #             radio_no_map = gr.Radio(
        #                 value="gpt-3.5-turbo",
        #                 choices=["gpt-3.5-turbo", "gpt-4", "models/text-bison-001"],
        #                 label="Model choices",
        #             )

        #             query_validation_no_map = gr.Textbox(
        #                 label="Query validation information", lines=2
        #             )
        #         with gr.Column():
        #             text_output_no_map = gr.Textbox(
        #                 value="Your itinerary will appear here",
        #                 label="Itinerary suggestion",
        #                 lines=3,
        #             )
        #     text_button = gr.Button("Generate")

    # map_button.click(
    #     generic_map,
    #     inputs=[text_input_map, radio_map],
    #     outputs=[map_output, itinerary_output, query_validation_text],
    # )
    # text_button.click(
    #     generic_map,
    #     inputs=[text_input_no_map, radio_no_map],
    #     outputs=[text_output_no_map, query_validation_no_map],
    # )
    #app.load(map)

app.launch()