Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -198,7 +198,9 @@ def generate(system, prompt):
|
|
198 |
# Add assistant response to chat history
|
199 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
200 |
|
201 |
-
|
|
|
|
|
202 |
# UI main #####################################################
|
203 |
|
204 |
tab1, tab2 = st.tabs(["Prompts Library", "Chatbot"])
|
@@ -244,6 +246,8 @@ with tab1:
|
|
244 |
delete_prompt(f["title"])
|
245 |
st.rerun()
|
246 |
with tab2:
|
|
|
|
|
247 |
# Initialize chat history
|
248 |
if "messages" not in st.session_state:
|
249 |
st.session_state.messages = []
|
|
|
198 |
# Add assistant response to chat history
|
199 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
200 |
|
201 |
+
def clear():
|
202 |
+
for key in st.session_state.keys():
|
203 |
+
del st.session_state[key]
|
204 |
# UI main #####################################################
|
205 |
|
206 |
tab1, tab2 = st.tabs(["Prompts Library", "Chatbot"])
|
|
|
246 |
delete_prompt(f["title"])
|
247 |
st.rerun()
|
248 |
with tab2:
|
249 |
+
if st.button("Clear chatbot history", type="secondary"):
|
250 |
+
clear()
|
251 |
# Initialize chat history
|
252 |
if "messages" not in st.session_state:
|
253 |
st.session_state.messages = []
|