Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 1174 |
-
|
| 1175 |
-
|
| 1176 |
-
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|