m-ric HF staff commited on
Commit
34bd01c
1 Parent(s): e3ef8fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -115,6 +115,13 @@ def run_display(text):
115
  map = create_map_from_markers(dataframe)
116
  return map, rationale
117
 
 
 
 
 
 
 
 
118
 
119
  with gr.Blocks(
120
  theme=gr.themes.Soft(
@@ -122,6 +129,7 @@ with gr.Blocks(
122
  secondary_hue=gr.themes.colors.blue,
123
  )
124
  ) as demo:
 
125
  text = gr.Textbox(
126
  label="Trip description",
127
  value=description_sf,
@@ -135,6 +143,8 @@ with gr.Blocks(
135
  starting_map = create_map_from_markers(example_dataframe)
136
  map = Folium(value=starting_map, height=600, label="Chosen locations")
137
 
 
 
138
  button.click(run_display, inputs=[text], outputs=[map, display_rationale])
139
 
140
  if __name__ == "__main__":
 
115
  map = create_map_from_markers(dataframe)
116
  return map, rationale
117
 
118
+ df_examples = pd.DataFrame.from_dict({"description": [description_loire], "output": [output_example_loire]})
119
+
120
+ def select_example(df, data: gr.SelectData):
121
+ row = df.iloc[data.index[0], :]
122
+ dataframe, rationale = parse_llm_output(row['output'])
123
+ return create_map_from_markers(dataframe), rationale
124
+
125
 
126
  with gr.Blocks(
127
  theme=gr.themes.Soft(
 
129
  secondary_hue=gr.themes.colors.blue,
130
  )
131
  ) as demo:
132
+ gr.Markdown("# 🗺️ LLM trip planner (based on Mixtral)")
133
  text = gr.Textbox(
134
  label="Trip description",
135
  value=description_sf,
 
143
  starting_map = create_map_from_markers(example_dataframe)
144
  map = Folium(value=starting_map, height=600, label="Chosen locations")
145
 
146
+ clickable_examples = gr.DataFrame(value=df_examples, height=200)
147
+ clickable_examples.select(select_example, clickable_examples, outputs=[map, display_rationale])
148
  button.click(run_display, inputs=[text], outputs=[map, display_rationale])
149
 
150
  if __name__ == "__main__":