openfree commited on
Commit
9f70594
ยท
verified ยท
1 Parent(s): 7ba33cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -42
app.py CHANGED
@@ -1218,45 +1218,45 @@ if st.session_state.generation_complete:
1218
 
1219
 
1220
 
1221
- # AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค ํƒญ (์ œ๋ฏธ๋‚˜์ด ์ ์šฉ)
1222
- with chatbot_tab:
1223
- st.markdown("### AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค")
1224
- # ๋Œ€ํ™” ๊ธฐ๋ก์„ ์„ธ์…˜ ์ƒํƒœ์— ์ €์žฅ (๋ฉ”์‹œ์ง€, ๋ฐœ์‹ ์ž, ํƒ€์ž„์Šคํƒฌํ”„)
1225
- if "chat_history" not in st.session_state:
1226
- st.session_state.chat_history = []
1227
-
1228
- # ์‚ฌ์šฉ์ž ์ž…๋ ฅ์ฐฝ ๋ฐ ์ „์†ก ๋ฒ„ํŠผ
1229
- user_message = st.text_input("๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", key="chat_input")
1230
- if st.button("์ „์†ก", key="send_button"):
1231
- if user_message:
1232
- # ์ œ๋ฏธ๋‚˜์ด ๊ธฐ๋ฐ˜ ์ฑ—๋ด‡ ์‘๋‹ต: run_task()๋ฅผ ํ™œ์šฉํ•˜์—ฌ chatbot_task์— ์งˆ์˜
1233
- response = run_task(chatbot_task, user_message)
1234
- st.session_state.chat_history.append({
1235
- "speaker": "์‚ฌ์šฉ์ž",
1236
- "message": user_message,
1237
- "time": datetime.now()
1238
- })
1239
- st.session_state.chat_history.append({
1240
- "speaker": "AI",
1241
- "message": response,
1242
- "time": datetime.now()
1243
- })
1244
-
1245
- # ๋Œ€ํ™” ๊ธฐ๋ก ์ถœ๋ ฅ (ํƒ€์ž„์Šคํƒฌํ”„ ํฌํ•จ, ์Šคํฌ๋กค ๊ฐ€๋Šฅํ•œ ์˜์—ญ)
1246
- st.markdown("<div style='max-height:400px; overflow-y:auto; padding:10px; border:1px solid #eaeaea; border-radius:6px;'>", unsafe_allow_html=True)
1247
- for chat in st.session_state.chat_history:
1248
- time_str = chat["time"].strftime("%H:%M:%S")
1249
- st.markdown(f"**{chat['speaker']}** ({time_str}): {chat['message']}")
1250
- st.markdown("</div>", unsafe_allow_html=True)
1251
-
1252
- # Clear ๋ฒ„ํŠผ ์ถ”๊ฐ€
1253
- if st.button("Clear", key="clear_button"):
1254
- st.session_state.chat_history = []
1255
- st.session_state.chat_input = ""
1256
- st.experimental_rerun()
1257
-
1258
- st.markdown("""
1259
- <div style="margin-top: 50px; text-align: center; padding: 20px; color: #6c757d; font-size: 0.8rem;">
1260
- <p>""" + t("built_with") + """</p>
1261
- </div>
1262
- """, unsafe_allow_html=True)
 
1218
 
1219
 
1220
 
1221
+ # AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค ํƒญ (์ œ๋ฏธ๋‚˜์ด ์ ์šฉ)
1222
+ with chatbot_tab:
1223
+ st.markdown("### AI ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค")
1224
+ # ๋Œ€ํ™” ๊ธฐ๋ก์„ ์„ธ์…˜ ์ƒํƒœ์— ์ €์žฅ (๋ฉ”์‹œ์ง€, ๋ฐœ์‹ ์ž, ํƒ€์ž„์Šคํƒฌํ”„)
1225
+ if "chat_history" not in st.session_state:
1226
+ st.session_state.chat_history = []
1227
+
1228
+ # ์‚ฌ์šฉ์ž ์ž…๋ ฅ์ฐฝ ๋ฐ ์ „์†ก ๋ฒ„ํŠผ
1229
+ user_message = st.text_input("๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”:", key="chat_input")
1230
+ if st.button("์ „์†ก", key="send_button"):
1231
+ if user_message:
1232
+ # ์ œ๋ฏธ๋‚˜์ด ๊ธฐ๋ฐ˜ ์ฑ—๋ด‡ ์‘๋‹ต: run_task()๋ฅผ ํ™œ์šฉํ•˜์—ฌ chatbot_task์— ์งˆ์˜
1233
+ response = run_task(chatbot_task, user_message)
1234
+ st.session_state.chat_history.append({
1235
+ "speaker": "์‚ฌ์šฉ์ž",
1236
+ "message": user_message,
1237
+ "time": datetime.now()
1238
+ })
1239
+ st.session_state.chat_history.append({
1240
+ "speaker": "AI",
1241
+ "message": response,
1242
+ "time": datetime.now()
1243
+ })
1244
+
1245
+ # ๋Œ€ํ™” ๊ธฐ๋ก ์ถœ๋ ฅ (ํƒ€์ž„์Šคํƒฌํ”„ ํฌํ•จ, ์Šคํฌ๋กค ๊ฐ€๋Šฅํ•œ ์˜์—ญ)
1246
+ st.markdown("<div style='max-height:400px; overflow-y:auto; padding:10px; border:1px solid #eaeaea; border-radius:6px;'>", unsafe_allow_html=True)
1247
+ for chat in st.session_state.chat_history:
1248
+ time_str = chat["time"].strftime("%H:%M:%S")
1249
+ st.markdown(f"**{chat['speaker']}** ({time_str}): {chat['message']}")
1250
+ st.markdown("</div>", unsafe_allow_html=True)
1251
+
1252
+ # Clear ๋ฒ„ํŠผ ์ถ”๊ฐ€ (์ˆ˜์ •๋œ ๋ถ€๋ถ„)
1253
+ if st.button("Clear", key="clear_button"):
1254
+ st.session_state.chat_history = []
1255
+ st.session_state.pop("chat_input", None) # chat_input ํ‚ค๋ฅผ ์‚ญ์ œํ•˜์—ฌ ์œ„์ ฏ์˜ ๊ฐ’์„ ์ดˆ๊ธฐํ™”
1256
+ st.experimental_rerun()
1257
+
1258
+ st.markdown("""
1259
+ <div style="margin-top: 50px; text-align: center; padding: 20px; color: #6c757d; font-size: 0.8rem;">
1260
+ <p>""" + t("built_with") + """</p>
1261
+ </div>
1262
+ """, unsafe_allow_html=True)