m-ric HF staff commited on
Commit
309caec
1 Parent(s): efcf428

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -6
app.py CHANGED
@@ -7,6 +7,16 @@ import pandas as pd
7
  from gradio_folium import Folium
8
  import folium
9
  from huggingface_hub import InferenceClient
 
 
 
 
 
 
 
 
 
 
10
 
11
  repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
12
  llm_client = InferenceClient(model=repo_id, timeout=180)
@@ -22,7 +32,7 @@ Key points: [
22
  {"name": "Cable Car Museum", "description": "The Cable Car Museum is a museum in San Francisco that showcases the history of the city's iconic cable cars. It's a great place to learn about the technology and history behind these unique vehicles."},
23
  {"name": "Union Square, San Francisco", "description": "Union Square is a public plaza in San Francisco, known for its shopping, dining, and entertainment options. Relax, grab a bite to eat, and do some shopping."},
24
  {"name": "Chinatown, San Francisco", "description": "Chinatown is a vibrant neighborhood in San Francisco, known for its Chinese culture, history, and cuisine. It's a great place to explore the streets, try some delicious food, and learn about Chinese culture."},
25
- {"name": "Coit Tower, San Francisco", "description": "Coit Tower is a historic tower in San Francisco, known for its panoramic views of the city. You can end your day here, taking in the sights and sounds of the city from above."}
26
  ]
27
  """
28
 
@@ -44,11 +54,11 @@ Key points: [
44
  {"name": "Château de Chambord", "description": "Château de Chambord is the largest and most recognizable château in the Loire Valley, known for its French Renaissance architecture and beautiful gardens."},
45
  {"name": "Château de Cheverny", "description": "Château de Cheverny is a small but charming château with beautiful gardens, known for its French classical architecture and rich history."},
46
  {"name": "Château de Chaumont-sur-Loire", "description": "Château de Chaumont-sur-Loire is a château with a stunning view of the Loire River, known for its beautiful gardens and rich history."},
47
- {"name": "Château de Chenonceau", "description": "Château de Chenonceau is a stunning château built over the River Cher, known for its beautiful gardens and rich history."},
48
- {"name": "Château d'Amboise", "description": "Château d'Amboise is a historic château with ties to the French Renaissance, known for its beautiful gardens and stunning views of the Loire Valley."},
49
  {"name": "Château de Villandry", "description": "Château de Villandry is known for its beautiful gardens, featuring a water garden, ornamental flower gardens, and vegetable gardens."},
50
  {"name": "Château d'Azay-le-Rideau", "description": "Château d'Azay-le-Rideau is a charming château with a moat, known for its French Renaissance architecture and beautiful gardens."},
51
- {"name": "Château d'Ussé", "description": "Château d'Ussé is a fairy-tale like château said to have inspired Sleeping Beauty, known for its beautiful gardens and stunning views of the Indre Valley."},
52
  ]
53
  """
54
 
@@ -100,10 +110,40 @@ Key points: [
100
  {"name": "Las Vegas Chinatown, Las Vegas, NV", "description": "Las Vegas Chinatown is a vibrant neighborhood located just west of the Las Vegas Strip, known for its beautiful architecture, traditional Chinese markets, and delicious food. It is a popular destination for tourists and locals alike, offering a unique blend of Chinese culture and American history."}
101
  ]
102
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  def generate_key_points(text):
104
  prompt = f"""
105
  Please generate a set of key geographical points for the following description: {text}, as a json list of less than 10 dictionnaries with the following keys: 'name', 'description'. Precise the full location in the 'name' if there is a possible ambiguity.
106
  Generally try to minimze the distance between locations. Always think of the transportation means that you want to use, and the timing: morning, afternoon, where to sleep.
 
107
 
108
  For instance:
109
  Description: {description_sf}
@@ -175,9 +215,9 @@ def run_display(text):
175
  df_examples = pd.DataFrame.from_dict(
176
  [
177
  {"description": description_loire, "output": output_example_loire},
178
- {"description": description_sf, "output": output_example_sf},
179
  {"description": description_aligned, "output": output_example_aligned},
180
  {"description": description_chinatown, "output": output_example_chinatown},
 
181
  ]
182
  )
183
 
@@ -209,7 +249,7 @@ with gr.Blocks(
209
  map = Folium(value=starting_map, height=600, label="Chosen locations")
210
  button.click(run_display, inputs=[text], outputs=[map, display_rationale])
211
 
212
- gr.Markdown("### Examples")
213
  clickable_examples = gr.DataFrame(value=df_examples, height=200)
214
  clickable_examples.select(
215
  select_example, clickable_examples, outputs=[text, map, display_rationale]
 
7
  from gradio_folium import Folium
8
  import folium
9
  from huggingface_hub import InferenceClient
10
+ from geopy.geocoders import Nominatim
11
+
12
+ geolocator = Nominatim(user_agent="HF-trip-planner")
13
+
14
+ def get_coordinates(address):
15
+ location = geolocator.geocode(address)
16
+ if location:
17
+ return (location.latitude, location.longitude)
18
+ else:
19
+ return None
20
 
21
  repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
22
  llm_client = InferenceClient(model=repo_id, timeout=180)
 
32
  {"name": "Cable Car Museum", "description": "The Cable Car Museum is a museum in San Francisco that showcases the history of the city's iconic cable cars. It's a great place to learn about the technology and history behind these unique vehicles."},
33
  {"name": "Union Square, San Francisco", "description": "Union Square is a public plaza in San Francisco, known for its shopping, dining, and entertainment options. Relax, grab a bite to eat, and do some shopping."},
34
  {"name": "Chinatown, San Francisco", "description": "Chinatown is a vibrant neighborhood in San Francisco, known for its Chinese culture, history, and cuisine. It's a great place to explore the streets, try some delicious food, and learn about Chinese culture."},
35
+ {"name": "Coit Tower, San Francisco", "description": "Coit Tower is a tower in San Francisco with panoramic views of the city. You can end your day here, taking in the sights and sounds of the city from above."}
36
  ]
37
  """
38
 
 
54
  {"name": "Château de Chambord", "description": "Château de Chambord is the largest and most recognizable château in the Loire Valley, known for its French Renaissance architecture and beautiful gardens."},
55
  {"name": "Château de Cheverny", "description": "Château de Cheverny is a small but charming château with beautiful gardens, known for its French classical architecture and rich history."},
56
  {"name": "Château de Chaumont-sur-Loire", "description": "Château de Chaumont-sur-Loire is a château with a stunning view of the Loire River, known for its beautiful gardens and rich history."},
57
+ {"name": "Château de Chenonceau", "description": "Château de Chenonceau, known for its beautiful gardens and rich history, is a stunning château built over the River Cher."},
58
+ {"name": "Château d'Amboise", "description": "Château d'Amboise has ties to the French Renaissance: this château is known for its beautiful gardens and stunning views of the Loire Valley."},
59
  {"name": "Château de Villandry", "description": "Château de Villandry is known for its beautiful gardens, featuring a water garden, ornamental flower gardens, and vegetable gardens."},
60
  {"name": "Château d'Azay-le-Rideau", "description": "Château d'Azay-le-Rideau is a charming château with a moat, known for its French Renaissance architecture and beautiful gardens."},
61
+ {"name": "Château d'Ussé", "description": "Château d'Ussé is a fairy-tale like château that displays beautiful gardens and stunning views of the Indre Valley. It is said to have inspired Sleeping Beauty,"},
62
  ]
63
  """
64
 
 
110
  {"name": "Las Vegas Chinatown, Las Vegas, NV", "description": "Las Vegas Chinatown is a vibrant neighborhood located just west of the Las Vegas Strip, known for its beautiful architecture, traditional Chinese markets, and delicious food. It is a popular destination for tourists and locals alike, offering a unique blend of Chinese culture and American history."}
111
  ]
112
  """
113
+
114
+ description_taiwan= "A two-week trip on train around Taiwan."
115
+ output_example_taiwan = """Since this is a train trip, I will make sure to plan the trip around train stations and routes. I will also try to minimize the distance between locations and plan the trip so that it can be done in two weeks. I will also try to include a variety of activities and sights to see, such as cultural experiences, natural wonders, and historical sites.
116
+
117
+ Here is a suggested itinerary for a two-week train trip around Taiwan:
118
+
119
+ 1. Start in Taipei, the capital city of Taiwan. Visit the National Palace Museum, Taipei 101, and the Chiang Kai-shek Memorial Hall.
120
+ 2. Take the train to Hualien, a coastal city on the east coast of Taiwan. Visit the Taroko National Park, known for its stunning marble cliffs and hiking trails.
121
+ 3. Take the train to Taitung, a city on the southeast coast of Taiwan. Visit the Taitung Forest Park and the Green Island, a volcanic island known for its clear waters and coral reefs.
122
+ 4. Take the train to Kaohsiung, a city on the southwest coast of Taiwan. Visit the Fo Guang Shan Buddha Museum, the Love River, and the Pier-2 Art Center.
123
+ 5. Take the train to Tainan, a city on the southwest coast of Taiwan. Visit the Anping Old Fort, the Chimei Museum, and the National Museum of Taiwanese Literature.
124
+ 6. Take the train to Chiayi, a city on the west coast of Taiwan. Visit the Alishan National Scenic Area, known for its mountain scenery and sunrise views.
125
+ 7. Take the train to Taichung, a city in the west-central part of Taiwan. Visit the National Taiwan Museum of Fine Arts, the Taichung Park, and the Miyahara Ice Cream Shop.
126
+ 8. Take the train to Hsinchu, a city in the northwest part of Taiwan. Visit the Hsinchu Science Park and the Hsinchu Zoo.
127
+ 9. Take the train back to Taipei. Visit the Taipei Zoo, the Maokong Gondola, and the Yangmingshan National Park.
128
+
129
+ Key points: [
130
+ {"name": "Taipei, Taiwan", "description": "Taipei is the capital city of Taiwan, known for its vibrant culture, rich history, and modern skyline. Visit the National Palace Museum, Taipei 101, and the Chiang Kai-shek Memorial Hall."},
131
+ {"name": "Hualien, Taiwan", "description": "Hualien is a coastal city on the east coast of Taiwan, known for its stunning natural beauty and outdoor activities. Visit the Taroko National Park, known for its marble cliffs and hiking trails."},
132
+ {"name": "Taitung, Taiwan", "description": "Taitung is a city on the southeast coast of Taiwan, known for its beautiful beaches and outdoor activities. Visit the Taitung Forest Park and the Green Island, a volcanic island known for its clear waters and coral reefs."},
133
+ {"name": "Kaohsiung, Taiwan", "description": "Kaohsiung is a city on the southwest coast of Taiwan, known for its vibrant culture, rich history, and modern skyline. Visit the Fo Guang Shan Buddha Museum, the Love River, and the Pier-2 Art Center."},
134
+ {"name": "Tainan, Taiwan", "description": "Tainan is a city on the southwest coast of Taiwan, known for its rich history, cultural heritage, and delicious food. Visit the Anping Old Fort, the Chimei Museum, and the National Museum of Taiwanese Literature."},
135
+ {"name": "Chiayi, Taiwan", "description": "Chiayi is a city on the west coast of Taiwan, known for its stunning mountain scenery and outdoor activities. Visit the Alishan National Scenic Area, known for its mountain scenery and sunrise views."},
136
+ {"name": "Taichung, Taiwan", "description": "Taichung is a city in the west-central part of Taiwan, known for its vibrant culture, rich history, and modern skyline. Visit the National Taiwan Museum of Fine Arts, the Taichung Park, and the Miyahara Ice Cream Shop."},
137
+ {"name": "Hsinchu, Taiwan", "description": "Hsinchu is a city in the northwest part of Taiwan, known for its high-tech industry and beautiful natural scenery. Visit the Hsinchu Science Park and the Hsinchu Zoo."},
138
+ ]
139
+ """
140
+
141
+
142
  def generate_key_points(text):
143
  prompt = f"""
144
  Please generate a set of key geographical points for the following description: {text}, as a json list of less than 10 dictionnaries with the following keys: 'name', 'description'. Precise the full location in the 'name' if there is a possible ambiguity.
145
  Generally try to minimze the distance between locations. Always think of the transportation means that you want to use, and the timing: morning, afternoon, where to sleep.
146
+ Only generate a 'Thought:' and a 'Key points:' sections, nothing else.
147
 
148
  For instance:
149
  Description: {description_sf}
 
215
  df_examples = pd.DataFrame.from_dict(
216
  [
217
  {"description": description_loire, "output": output_example_loire},
 
218
  {"description": description_aligned, "output": output_example_aligned},
219
  {"description": description_chinatown, "output": output_example_chinatown},
220
+ {"description": description_taiwan, "output": output_example_taiwan},
221
  ]
222
  )
223
 
 
249
  map = Folium(value=starting_map, height=600, label="Chosen locations")
250
  button.click(run_display, inputs=[text], outputs=[map, display_rationale])
251
 
252
+ gr.Markdown("### Other examples")
253
  clickable_examples = gr.DataFrame(value=df_examples, height=200)
254
  clickable_examples.select(
255
  select_example, clickable_examples, outputs=[text, map, display_rationale]