Update app.py
Browse files
app.py
CHANGED
@@ -140,19 +140,22 @@ def get_response(system_message, chat_history, user_text, max_new_tokens=256, co
|
|
140 |
|
141 |
# Chat interface
|
142 |
chat_interface = st.container()
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
st.
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
156 |
|
157 |
if st.button("Continue"):
|
158 |
st.session_state.need_continue = True
|
@@ -196,6 +199,7 @@ if st.session_state.get('need_continue', False):
|
|
196 |
continue_last=True
|
197 |
)
|
198 |
st.markdown(response)
|
|
|
199 |
|
200 |
# Reset the flag
|
201 |
st.session_state.need_continue = False
|
|
|
140 |
|
141 |
# Chat interface
|
142 |
chat_interface = st.container()
|
143 |
+
def refresh_chat():
|
144 |
+
with chat_interface:
|
145 |
+
output_container = st.container()
|
146 |
+
|
147 |
+
# Display chat messages
|
148 |
+
with output_container:
|
149 |
+
for idx, message in enumerate(st.session_state.chat_history):
|
150 |
+
if message['role'] == 'system':
|
151 |
+
continue
|
152 |
+
with st.chat_message(message['role'], avatar=st.session_state.avatars[message['role']]):
|
153 |
+
st.markdown(message['content'])
|
154 |
+
|
155 |
+
# If this is the last assistant message, add the "Continue" button
|
156 |
+
# if idx == len(st.session_state.chat_history) - 1 and message['role'] == 'assistant':
|
157 |
+
|
158 |
+
refresh_chat()
|
159 |
|
160 |
if st.button("Continue"):
|
161 |
st.session_state.need_continue = True
|
|
|
199 |
continue_last=True
|
200 |
)
|
201 |
st.markdown(response)
|
202 |
+
refresh_chat()
|
203 |
|
204 |
# Reset the flag
|
205 |
st.session_state.need_continue = False
|