Update app.py
Browse files
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(
|
| 112 |
-
# st.write(f"<div style='color: gray;'>User: {message['content']}</div>", unsafe_allow_html=True)
|
| 113 |
else:
|
| 114 |
-
st.write(
|
| 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:
|