kaleidoskop-hug commited on
Commit
2b80c2b
·
verified ·
1 Parent(s): d59ddfd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -13
app.py CHANGED
@@ -76,8 +76,7 @@ if "messages" not in st.session_state:
76
 
77
  def remove_message(position):
78
  st.toast("try to remove message no: " + str(position-1) + " and "+ str(position))
79
- del st.session_state.messages[position-1:position]
80
-
81
 
82
  if "remove" not in st.session_state:
83
  st.session_state.remove= False
@@ -85,14 +84,6 @@ if "remove" not in st.session_state:
85
  def remove_click():
86
  st.session_state.remove= True
87
 
88
- if st.session_state.remove:
89
- lastmessage = st.session_state.messages.pop()
90
- prelastmessage = st.session_state.messages.pop()
91
- st.toast("popped msg: " + lastmessage["content"] + " // model: " + model_links[selected_model])
92
- st.session_state.remove = False
93
- st.rerun()
94
-
95
-
96
  # Display chat messages from history on app rerun
97
  pos = 0
98
  for message in st.session_state.messages:
@@ -128,6 +119,3 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
128
  col2.button("remove-"+str(pos), key="button_remove_message_"+str(pos), args=[pos], on_click=remove_message)
129
 
130
  st.session_state.messages.append({"role": "assistant", "content": response})
131
-
132
- if len(st.session_state.messages)>0:
133
- st.button("remove last conversation", key="removeButton", on_click=remove_click)
 
76
 
77
  def remove_message(position):
78
  st.toast("try to remove message no: " + str(position-1) + " and "+ str(position))
79
+ del st.session_state.messages[position-2:position]
 
80
 
81
  if "remove" not in st.session_state:
82
  st.session_state.remove= False
 
84
  def remove_click():
85
  st.session_state.remove= True
86
 
 
 
 
 
 
 
 
 
87
  # Display chat messages from history on app rerun
88
  pos = 0
89
  for message in st.session_state.messages:
 
119
  col2.button("remove-"+str(pos), key="button_remove_message_"+str(pos), args=[pos], on_click=remove_message)
120
 
121
  st.session_state.messages.append({"role": "assistant", "content": response})