openfree commited on
Commit
a808da1
ยท
verified ยท
1 Parent(s): 4791a6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -29
app.py CHANGED
@@ -10,6 +10,7 @@ from travel import (
10
  activities_task, dining_task, itinerary_task, chatbot_task,
11
  run_task
12
  )
 
13
 
14
  # st.set_page_config()๋Š” ๋‹ค๋ฅธ Streamlit ํ•จ์ˆ˜๋ณด๋‹ค ๊ฐ€์žฅ ๋จผ์ € ์‹คํ–‰๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
15
  st.set_page_config(
@@ -837,12 +838,13 @@ if not st.session_state.generation_complete:
837
  special_requirements = st.text_area("Special Requirements", placeholder="Dietary restrictions, accessibility needs...")
838
  submit_button = st.form_submit_button(t("submit"))
839
  st.markdown('</div>', unsafe_allow_html=True)
840
-
841
  if submit_button:
842
  if not origin or not destination:
843
  st.error(t("error_origin_destination"))
844
  else:
845
  st.session_state.form_submitted = True
 
846
  user_input = {
847
  "origin": origin,
848
  "destination": destination,
@@ -854,6 +856,7 @@ if not st.session_state.generation_complete:
854
  "preferences": preferences,
855
  "special_requirements": special_requirements
856
  }
 
857
  st.session_state.user_input = user_input # ์ €์žฅํ•˜์—ฌ ์ดํ›„ ์ง€๋„์— ํ™œ์šฉ
858
  # ๊ธฐ์กด์˜ ์—ฌํ–‰ ์š”์ฒญ ํ”„๋กฌํ”„ํŠธ
859
  input_context = f"""Travel Request Details:
@@ -1167,35 +1170,53 @@ if st.session_state.generation_complete:
1167
  with col2:
1168
  st.markdown("### " + t("save_for_mobile"))
1169
  st.markdown("*Coming soon: QR code for easy access on your phone*")
1170
-
1171
- # ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ์ง€๋„ ๋ฐ ์‹œ๊ฐํ™” ํƒญ
 
1172
  with map_tab:
1173
- st.markdown("### ๋ชฉ์ ์ง€ ์ง€๋„")
1174
- # ์˜ˆ์‹œ: ๋ชฉ์ ์ง€ ์ฃผ๋ณ€์˜ ์ฃผ์š” ๋ช…์†Œ ์ขŒํ‘œ ๋ฐ์ดํ„ฐ (์‹ค์ œ API๋‚˜ DB๋ฅผ ํ†ตํ•ด ๋™์ ์œผ๋กœ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Œ)
1175
- map_data = pd.DataFrame({
1176
- "lat": [48.8584, 48.8606, 48.8529],
1177
- "lon": [2.2945, 2.3376, 2.3500],
1178
- "name": ["Eiffel Tower", "Louvre Museum", "Notre Dame"]
1179
- })
1180
- # ๊ธฐ๋ณธ ์ง€๋„ ์ถœ๋ ฅ (st.map)
1181
- st.map(map_data)
1182
-
1183
- st.markdown("#### Pydeck์„ ํ™œ์šฉํ•œ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ์ง€๋„ ์˜ˆ์‹œ")
1184
- layer = pdk.Layer(
1185
- "ScatterplotLayer",
1186
- data=map_data,
1187
- get_position='[lon, lat]',
1188
- get_color='[200, 30, 0, 160]',
1189
- get_radius=200,
1190
- )
1191
- view_state = pdk.ViewState(
1192
- latitude=48.8566,
1193
- longitude=2.3522,
1194
- zoom=12,
1195
- pitch=50,
1196
- )
1197
- deck_chart = pdk.Deck(layers=[layer], initial_view_state=view_state)
1198
- st.pydeck_chart(deck_chart)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1199
 
1200
  # AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค ํƒญ (์ œ๋ฏธ๋‚˜์ด ์ ์šฉ)
1201
  with chatbot_tab:
 
10
  activities_task, dining_task, itinerary_task, chatbot_task,
11
  run_task
12
  )
13
+ from geopy.geocoders import Nominatim
14
 
15
  # st.set_page_config()๋Š” ๋‹ค๋ฅธ Streamlit ํ•จ์ˆ˜๋ณด๋‹ค ๊ฐ€์žฅ ๋จผ์ € ์‹คํ–‰๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
16
  st.set_page_config(
 
838
  special_requirements = st.text_area("Special Requirements", placeholder="Dietary restrictions, accessibility needs...")
839
  submit_button = st.form_submit_button(t("submit"))
840
  st.markdown('</div>', unsafe_allow_html=True)
841
+
842
  if submit_button:
843
  if not origin or not destination:
844
  st.error(t("error_origin_destination"))
845
  else:
846
  st.session_state.form_submitted = True
847
+ st.session_state.destination = destination # ๋ชฉ์ ์ง€๋ฅผ session_state์— ์ €์žฅ
848
  user_input = {
849
  "origin": origin,
850
  "destination": destination,
 
856
  "preferences": preferences,
857
  "special_requirements": special_requirements
858
  }
859
+
860
  st.session_state.user_input = user_input # ์ €์žฅํ•˜์—ฌ ์ดํ›„ ์ง€๋„์— ํ™œ์šฉ
861
  # ๊ธฐ์กด์˜ ์—ฌํ–‰ ์š”์ฒญ ํ”„๋กฌํ”„ํŠธ
862
  input_context = f"""Travel Request Details:
 
1170
  with col2:
1171
  st.markdown("### " + t("save_for_mobile"))
1172
  st.markdown("*Coming soon: QR code for easy access on your phone*")
1173
+
1174
+
1175
+
1176
  with map_tab:
1177
+ st.markdown("### ๋ชฉ์ ์ง€ ์ง€๋„")
1178
+ # session_state์—์„œ ๋ชฉ์ ์ง€ ๊ฐ’์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค. (์—†์„ ๊ฒฝ์šฐ ๊ธฐ๋ณธ๊ฐ’ "Paris")
1179
+ dest = st.session_state.get("destination", "Paris")
1180
+
1181
+ # ์ง€์˜ค์ฝ”๋”ฉ์„ ํ†ตํ•ด ์œ„๋„, ๊ฒฝ๋„ ๊ตฌํ•˜๊ธฐ
1182
+ try:
1183
+ geolocator = Nominatim(user_agent="travel_app")
1184
+ location = geolocator.geocode(dest)
1185
+ if location:
1186
+ lat, lon = location.latitude, location.longitude
1187
+ else:
1188
+ st.error("์ž…๋ ฅํ•˜์‹  ๋ชฉ์ ์ง€๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ์ขŒํ‘œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.")
1189
+ lat, lon = 48.8566, 2.3522 # Paris ๊ธฐ๋ณธ๊ฐ’
1190
+ except Exception as e:
1191
+ st.error("์ง€์˜ค์ฝ”๋”ฉ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: " + str(e))
1192
+ lat, lon = 48.8566, 2.3522
1193
+
1194
+ # ์ง€๋„ ๋ฐ์ดํ„ฐ ์ƒ์„ฑ (ํ•„์š”์‹œ ๋ชฉ์ ์ง€ ์ฃผ๋ณ€ ๋ช…์†Œ ๋ฐ์ดํ„ฐ๋ฅผ ๋™์ ์œผ๋กœ ์ƒ์„ฑ ๊ฐ€๋Šฅ)
1195
+ map_data = pd.DataFrame({
1196
+ "lat": [lat],
1197
+ "lon": [lon],
1198
+ "name": [dest]
1199
+ })
1200
+ st.map(map_data)
1201
+
1202
+ st.markdown("#### Pydeck์„ ํ™œ์šฉํ•œ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ์ง€๋„ ์˜ˆ์‹œ")
1203
+ layer = pdk.Layer(
1204
+ "ScatterplotLayer",
1205
+ data=map_data,
1206
+ get_position='[lon, lat]',
1207
+ get_color='[200, 30, 0, 160]',
1208
+ get_radius=200,
1209
+ )
1210
+ view_state = pdk.ViewState(
1211
+ latitude=lat,
1212
+ longitude=lon,
1213
+ zoom=12,
1214
+ pitch=50,
1215
+ )
1216
+ deck_chart = pdk.Deck(layers=[layer], initial_view_state=view_state)
1217
+ st.pydeck_chart(deck_chart)
1218
+
1219
+
1220
 
1221
  # AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค ํƒญ (์ œ๋ฏธ๋‚˜์ด ์ ์šฉ)
1222
  with chatbot_tab: