lfoppiano commited on
Commit
b19b313
1 Parent(s): 13f46f5

avoid messages that are not paired with the response, in cases when the response fails

Browse files
Files changed (1) hide show
  1. streamlit_app.py +3 -2
streamlit_app.py CHANGED
@@ -334,8 +334,9 @@ if st.session_state.loaded_embeddings and question and len(question) > 0 and st.
334
 
335
  for id in range(0, len(st.session_state.messages), 2):
336
  question = st.session_state.messages[id]['content']
337
- answer = st.session_state.messages[id + 1]['content']
338
- st.session_state.memory.save_context({"input": question}, {"output": answer})
 
339
 
340
  elif st.session_state.loaded_embeddings and st.session_state.doc_id:
341
  play_old_messages()
 
334
 
335
  for id in range(0, len(st.session_state.messages), 2):
336
  question = st.session_state.messages[id]['content']
337
+ if len(st.session_state.messages) > id + 1:
338
+ answer = st.session_state.messages[id + 1]['content']
339
+ st.session_state.memory.save_context({"input": question}, {"output": answer})
340
 
341
  elif st.session_state.loaded_embeddings and st.session_state.doc_id:
342
  play_old_messages()