1MR commited on
Commit
f27fb7b
·
verified ·
1 Parent(s): 4cf25c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -101,6 +101,8 @@ def get_conversation_chain(vectorstore, tokenH):
101
 
102
 
103
  def handle_userinput(user_question):
 
 
104
  response = st.session_state.conversation(user_question)
105
 
106
  st.session_state.chat_history = [{"role": "user", "content": user_question}]
@@ -108,11 +110,9 @@ def handle_userinput(user_question):
108
 
109
  for i, message in enumerate(st.session_state.chat_history):
110
  if i % 2 == 0:
111
- st.write(user_template.replace("{{MSG}}", message.content), unsafe_allow_html=True
112
- # st.write(f"<div style='color: gray;'>User: {message['content']}</div>", unsafe_allow_html=True)
113
  else:
114
- st.write(bot_template.replace("{{MSG}}", message.content), unsafe_allow_html=True
115
- # st.write(f"<div style='color: black;'>Bot: {message['content']}</div>", unsafe_allow_html=True)
116
 
117
  # for i, message in enumerate(st.session_state.chat_history):
118
  # if i % 2 == 0:
 
101
 
102
 
103
  def handle_userinput(user_question):
104
+ if "chat_history" not in st.session_state:
105
+ st.session_state.chat_history = []
106
  response = st.session_state.conversation(user_question)
107
 
108
  st.session_state.chat_history = [{"role": "user", "content": user_question}]
 
110
 
111
  for i, message in enumerate(st.session_state.chat_history):
112
  if i % 2 == 0:
113
+ st.write(f"<div style='color: gray;'>User: {message['content']}</div>", unsafe_allow_html=True)
 
114
  else:
115
+ st.write(f"<div style='color: black;'>Bot: {message['content']}</div>", unsafe_allow_html=True)
 
116
 
117
  # for i, message in enumerate(st.session_state.chat_history):
118
  # if i % 2 == 0: