schuler commited on
Commit
ac6adc0
·
verified ·
1 Parent(s): 4492796

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
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
- with chat_interface:
144
- output_container = st.container()
145
-
146
- # Display chat messages
147
- with output_container:
148
- for idx, message in enumerate(st.session_state.chat_history):
149
- if message['role'] == 'system':
150
- continue
151
- with st.chat_message(message['role'], avatar=st.session_state.avatars[message['role']]):
152
- st.markdown(message['content'])
153
-
154
- # If this is the last assistant message, add the "Continue" button
155
- # if idx == len(st.session_state.chat_history) - 1 and message['role'] == 'assistant':
 
 
 
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