EUNSEO56 commited on
Commit
157130c
·
1 Parent(s): 97c9d86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -98,19 +98,16 @@ def handle_userinput(user_question):
98
  # 대화 체인을 사용하여 사용자 질문에 대한 응답을 생성합니다.
99
  response = st.session_state.conversation({'question': user_question})
100
  # 대화 기록을 저장합니다.
101
- if 'chat_history' not in st.session_state:
102
- st.session_state.chat_history = []
103
 
104
- st.session_state.chat_history.append({'user': user_question, 'bot': response['answer']})
 
 
 
 
 
 
105
 
106
- # 업데이트된 대화를 표시
107
- chat_output = ""
108
- for message in st.session_state.chat_history:
109
- chat_output += f"You: {message['user']}\n"
110
- chat_output += f"Bot: {message['bot']}\n"
111
-
112
- st.session_state.chat_output = chat_output
113
- st.text_area("Chat with the System:", value=chat_output, height=200, max_chars=None, key="chat_output", disabled=True)
114
 
115
  def main():
116
  load_dotenv()
 
98
  # 대화 체인을 사용하여 사용자 질문에 대한 응답을 생성합니다.
99
  response = st.session_state.conversation({'question': user_question})
100
  # 대화 기록을 저장합니다.
101
+ st.session_state.chat_history = response['chat_history']
 
102
 
103
+ for i, message in enumerate(st.session_state.chat_history):
104
+ if i % 2 == 0:
105
+ st.write(user_template.replace(
106
+ "{{MSG}}", message.content), unsafe_allow_html=True)
107
+ else:
108
+ st.write(bot_template.replace(
109
+ "{{MSG}}", message.content), unsafe_allow_html=True)
110
 
 
 
 
 
 
 
 
 
111
 
112
  def main():
113
  load_dotenv()