Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 1120 |
-
itinerary_tab, details_tab, download_tab = st.tabs([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 1160 |
-
|
| 1161 |
-
|
| 1162 |
-
|
| 1163 |
-
|
| 1164 |
-
|
| 1165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
|
|
|
|
|