Update app.py
Browse files
app.py
CHANGED
@@ -100,22 +100,19 @@ def handle_userinput(user_question):
|
|
100 |
|
101 |
# ๋ํ ์ฒด์ธ์ ์ฌ์ฉํ์ฌ ์ฌ์ฉ์ ์ง๋ฌธ์ ๋ํ ์๋ต์ ์์ฑํฉ๋๋ค.
|
102 |
st.session_state.conversation = {'question': user_question}
|
103 |
-
|
104 |
response = st.session_state.conversation
|
105 |
|
106 |
if 'chat_history' in response:
|
107 |
st.session_state.chat_history = response['chat_history']
|
108 |
for i, message in enumerate(st.session_state.chat_history):
|
109 |
if i % 2 == 0:
|
110 |
-
st.write(user_template.replace(
|
111 |
-
"{{MSG}}", message.content), unsafe_allow_html=True)
|
112 |
else:
|
113 |
-
st.write(bot_template.replace(
|
114 |
-
|
115 |
-
else:
|
116 |
# chat_history๊ฐ ์์ ๊ฒฝ์ฐ ์์ธ ์ฒ๋ฆฌ ๋๋ ๊ธฐ๋ณธ๊ฐ ์ค์
|
117 |
-
|
118 |
-
|
119 |
|
120 |
def main():
|
121 |
load_dotenv()
|
|
|
100 |
|
101 |
# ๋ํ ์ฒด์ธ์ ์ฌ์ฉํ์ฌ ์ฌ์ฉ์ ์ง๋ฌธ์ ๋ํ ์๋ต์ ์์ฑํฉ๋๋ค.
|
102 |
st.session_state.conversation = {'question': user_question}
|
|
|
103 |
response = st.session_state.conversation
|
104 |
|
105 |
if 'chat_history' in response:
|
106 |
st.session_state.chat_history = response['chat_history']
|
107 |
for i, message in enumerate(st.session_state.chat_history):
|
108 |
if i % 2 == 0:
|
109 |
+
st.write(user_template.replace("{{MSG}}", message.content), unsafe_allow_html=True)
|
|
|
110 |
else:
|
111 |
+
st.write(bot_template.replace("{{MSG}}", message.content), unsafe_allow_html=True)
|
112 |
+
else:
|
|
|
113 |
# chat_history๊ฐ ์์ ๊ฒฝ์ฐ ์์ธ ์ฒ๋ฆฌ ๋๋ ๊ธฐ๋ณธ๊ฐ ์ค์
|
114 |
+
st.session_state.chat_history = [] # ์์๋ก ๋น ๋ฆฌ์คํธ๋ฅผ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ค์
|
115 |
+
st.warning("Chat history not found or empty.")
|
116 |
|
117 |
def main():
|
118 |
load_dotenv()
|