openfree commited on
Commit
e3d9538
ยท
verified ยท
1 Parent(s): 1be6d32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -14
app.py CHANGED
@@ -4,9 +4,10 @@ import json
4
  from datetime import datetime, timedelta
5
  import base64
6
  import pandas as pd
 
7
  from travel import (
8
  destination_research_task, accommodation_task, transportation_task,
9
- activities_task, dining_task, itinerary_task,
10
  run_task
11
  )
12
 
@@ -1039,7 +1040,6 @@ Recommended Activities:
1039
  Dining Recommendations:
1040
  {dining_info}
1041
  """
1042
- # ์—ฌ๊ธฐ์„œ๋Š” language instruction์€ ์ด๋ฏธ ํฌํ•จ๋˜์ง€ ์•Š์€ ์›๋ณธ input_context์„ ์‚ฌ์šฉ(ํ•„์š”์— ๋”ฐ๋ผ ์ˆ˜์ • ๊ฐ€๋Šฅ)
1043
  itinerary = run_task_with_logs(
1044
  itinerary_task,
1045
  combined_info.format(duration=user_input['duration'], origin=user_input['origin'], destination=user_input['destination']),
@@ -1116,10 +1116,20 @@ if st.session_state.generation_complete:
1116
  </style>
1117
  """, unsafe_allow_html=True)
1118
 
1119
- st.markdown('<div class="modern-card">', unsafe_allow_html=True)
1120
- itinerary_tab, details_tab, download_tab = st.tabs(["๐Ÿ—’๏ธ " + t("full_itinerary"), "๐Ÿ’ผ " + t("details"), "๐Ÿ’พ " + t("download_share")])
 
 
 
 
 
 
 
 
1121
  with itinerary_tab:
1122
  st.text_area("Your Itinerary", st.session_state.generated_itinerary, height=600)
 
 
1123
  with details_tab:
1124
  agent_tabs = st.tabs(["๐ŸŒŽ Destination", "๐Ÿจ Accommodation", "๐Ÿš— Transportation", "๐ŸŽญ Activities", "๐Ÿฝ๏ธ Dining"])
1125
  with agent_tabs[0]:
@@ -1137,6 +1147,8 @@ if st.session_state.generation_complete:
1137
  with agent_tabs[4]:
1138
  st.markdown("### ๐Ÿฝ๏ธ Dining Recommendations")
1139
  st.markdown(st.session_state.results["dining_info"])
 
 
1140
  with download_tab:
1141
  col1, col2 = st.columns([2, 1])
1142
  with col1:
@@ -1154,20 +1166,69 @@ if st.session_state.generation_complete:
1154
  with col2:
1155
  st.markdown("### " + t("save_for_mobile"))
1156
  st.markdown("*Coming soon: QR code for easy access on your phone*")
1157
- st.markdown('</div>', unsafe_allow_html=True)
1158
 
1159
- if st.button(t("plan_another_trip"), key="reset_button"):
1160
- st.session_state.generated_itinerary = None
1161
- st.session_state.generation_complete = False
1162
- st.session_state.current_step = 0
1163
- st.session_state.form_submitted = False
1164
- st.session_state.results = {}
1165
- st.experimental_rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1166
 
1167
  st.markdown("""
1168
  <div style="margin-top: 50px; text-align: center; padding: 20px; color: #6c757d; font-size: 0.8rem;">
1169
  <p>""" + t("built_with") + """</p>
1170
  </div>
1171
  """, unsafe_allow_html=True)
1172
-
1173
-
 
4
  from datetime import datetime, timedelta
5
  import base64
6
  import pandas as pd
7
+ import pydeck as pdk
8
  from travel import (
9
  destination_research_task, accommodation_task, transportation_task,
10
+ activities_task, dining_task, itinerary_task, chatbot_task,
11
  run_task
12
  )
13
 
 
1040
  Dining Recommendations:
1041
  {dining_info}
1042
  """
 
1043
  itinerary = run_task_with_logs(
1044
  itinerary_task,
1045
  combined_info.format(duration=user_input['duration'], origin=user_input['origin'], destination=user_input['destination']),
 
1116
  </style>
1117
  """, unsafe_allow_html=True)
1118
 
1119
+ # ์ถ”๊ฐ€๋œ ํƒญ: ์ „์ฒด ์ผ์ •, ์ƒ์„ธ ์ •๋ณด, ๋‹ค์šด๋กœ๋“œ/๊ณต์œ , ์ง€๋„ ๋ฐ ์‹œ๊ฐํ™”, AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค
1120
+ itinerary_tab, details_tab, download_tab, map_tab, chatbot_tab = st.tabs([
1121
+ "๐Ÿ—’๏ธ " + t("full_itinerary"),
1122
+ "๐Ÿ’ผ " + t("details"),
1123
+ "๐Ÿ’พ " + t("download_share"),
1124
+ "๐Ÿ—บ๏ธ ์ง€๋„ ๋ฐ ์‹œ๊ฐํ™”",
1125
+ "๐Ÿค– ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค"
1126
+ ])
1127
+
1128
+ # ์ผ์ • ํƒญ
1129
  with itinerary_tab:
1130
  st.text_area("Your Itinerary", st.session_state.generated_itinerary, height=600)
1131
+
1132
+ # ์ƒ์„ธ ์ •๋ณด ํƒญ
1133
  with details_tab:
1134
  agent_tabs = st.tabs(["๐ŸŒŽ Destination", "๐Ÿจ Accommodation", "๐Ÿš— Transportation", "๐ŸŽญ Activities", "๐Ÿฝ๏ธ Dining"])
1135
  with agent_tabs[0]:
 
1147
  with agent_tabs[4]:
1148
  st.markdown("### ๐Ÿฝ๏ธ Dining Recommendations")
1149
  st.markdown(st.session_state.results["dining_info"])
1150
+
1151
+ # ๋‹ค์šด๋กœ๋“œ ๋ฐ ๊ณต์œ  ํƒญ
1152
  with download_tab:
1153
  col1, col2 = st.columns([2, 1])
1154
  with col1:
 
1166
  with col2:
1167
  st.markdown("### " + t("save_for_mobile"))
1168
  st.markdown("*Coming soon: QR code for easy access on your phone*")
 
1169
 
1170
+ # ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ์ง€๋„ ๋ฐ ์‹œ๊ฐํ™” ํƒญ
1171
+ with map_tab:
1172
+ st.markdown("### ๋ชฉ์ ์ง€ ์ง€๋„")
1173
+ # ์˜ˆ์‹œ: ๋ชฉ์ ์ง€ ์ฃผ๋ณ€์˜ ์ฃผ์š” ๋ช…์†Œ ์ขŒํ‘œ ๋ฐ์ดํ„ฐ (์‹ค์ œ API๋‚˜ DB๋ฅผ ํ†ตํ•ด ๋™์ ์œผ๋กœ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Œ)
1174
+ map_data = pd.DataFrame({
1175
+ "lat": [48.8584, 48.8606, 48.8529],
1176
+ "lon": [2.2945, 2.3376, 2.3500],
1177
+ "name": ["Eiffel Tower", "Louvre Museum", "Notre Dame"]
1178
+ })
1179
+ # ๊ธฐ๋ณธ ์ง€๋„ ์ถœ๋ ฅ (st.map)
1180
+ st.map(map_data)
1181
+
1182
+ st.markdown("#### Pydeck์„ ํ™œ์šฉํ•œ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ์ง€๋„ ์˜ˆ์‹œ")
1183
+ layer = pdk.Layer(
1184
+ "ScatterplotLayer",
1185
+ data=map_data,
1186
+ get_position='[lon, lat]',
1187
+ get_color='[200, 30, 0, 160]',
1188
+ get_radius=200,
1189
+ )
1190
+ view_state = pdk.ViewState(
1191
+ latitude=48.8566,
1192
+ longitude=2.3522,
1193
+ zoom=12,
1194
+ pitch=50,
1195
+ )
1196
+ deck_chart = pdk.Deck(layers=[layer], initial_view_state=view_state)
1197
+ st.pydeck_chart(deck_chart)
1198
+
1199
+ # AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค ํƒญ (์ œ๋ฏธ๋‚˜์ด ์ ์šฉ)
1200
+ with chatbot_tab:
1201
+ st.markdown("### AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค")
1202
+ # ๋Œ€ํ™” ๊ธฐ๋ก์„ ์„ธ์…˜ ์ƒํƒœ์— ์ €์žฅ (๋ฉ”์‹œ์ง€, ๋ฐœ์‹ ์ž, ํƒ€์ž„์Šคํƒฌํ”„)
1203
+ if "chat_history" not in st.session_state:
1204
+ st.session_state.chat_history = []
1205
+
1206
+ # ์‚ฌ์šฉ์ž ์ž…๋ ฅ์ฐฝ ๋ฐ ์ „์†ก ๋ฒ„ํŠผ
1207
+ user_message = st.text_input("๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", key="chat_input")
1208
+ if st.button("์ „์†ก", key="send_button"):
1209
+ if user_message:
1210
+ # ์ œ๋ฏธ๋‚˜์ด ๊ธฐ๋ฐ˜ ์ฑ—๋ด‡ ์‘๋‹ต: run_task()๋ฅผ ํ™œ์šฉํ•˜์—ฌ chatbot_task์— ์งˆ์˜
1211
+ response = run_task(chatbot_task, user_message)
1212
+ st.session_state.chat_history.append({
1213
+ "speaker": "์‚ฌ์šฉ์ž",
1214
+ "message": user_message,
1215
+ "time": datetime.now()
1216
+ })
1217
+ st.session_state.chat_history.append({
1218
+ "speaker": "AI",
1219
+ "message": response,
1220
+ "time": datetime.now()
1221
+ })
1222
+
1223
+ # ๋Œ€ํ™” ๊ธฐ๋ก ์ถœ๋ ฅ (ํƒ€์ž„์Šคํƒฌํ”„ ํฌํ•จ, ์Šคํฌ๋กค ๊ฐ€๋Šฅํ•œ ์˜์—ญ)
1224
+ st.markdown("<div style='max-height:400px; overflow-y:auto; padding:10px; border:1px solid #eaeaea; border-radius:6px;'>", unsafe_allow_html=True)
1225
+ for chat in st.session_state.chat_history:
1226
+ time_str = chat["time"].strftime("%H:%M:%S")
1227
+ st.markdown(f"**{chat['speaker']}** ({time_str}): {chat['message']}")
1228
+ st.markdown("</div>", unsafe_allow_html=True)
1229
 
1230
  st.markdown("""
1231
  <div style="margin-top: 50px; text-align: center; padding: 20px; color: #6c757d; font-size: 0.8rem;">
1232
  <p>""" + t("built_with") + """</p>
1233
  </div>
1234
  """, unsafe_allow_html=True)