Spaces:
Runtime error
Runtime error
Commit
·
2ae0133
1
Parent(s):
d78e5c8
Reset button
Browse filesAdded a reset button for History
app.py
CHANGED
@@ -75,6 +75,27 @@ for message in chat_history:
|
|
75 |
(message["role"], message["parts"][0]["text"]))
|
76 |
conn.commit()
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
conn.close()
|
79 |
|
80 |
# Separate section for image uploading
|
|
|
75 |
(message["role"], message["parts"][0]["text"]))
|
76 |
conn.commit()
|
77 |
|
78 |
+
# Create a placeholder for the history display
|
79 |
+
history_placeholder = st.empty()
|
80 |
+
|
81 |
+
# Use the key argument for the buttons
|
82 |
+
if st.button("Display History", key="display"):
|
83 |
+
c.execute("SELECT * FROM history")
|
84 |
+
rows = c.fetchall()
|
85 |
+
|
86 |
+
# Fill the placeholder with the history
|
87 |
+
for row in rows:
|
88 |
+
history_placeholder.markdown(f"**{row[0].title()}:** {row[1]}")
|
89 |
+
|
90 |
+
# Define a function to clear the placeholder
|
91 |
+
def clear_history():
|
92 |
+
history_placeholder.empty()
|
93 |
+
|
94 |
+
# Use the key argument for the buttons
|
95 |
+
if st.button("Reset History", key="reset", on_click=clear_history):
|
96 |
+
pass
|
97 |
+
|
98 |
+
|
99 |
conn.close()
|
100 |
|
101 |
# Separate section for image uploading
|