Spaces:
Runtime error
Runtime error
Commit
·
4ae2c46
1
Parent(s):
29c70a6
Update app.py
Browse files
app.py
CHANGED
@@ -49,6 +49,19 @@ if user_input:
|
|
49 |
response_text = response.text
|
50 |
|
51 |
chat_history.append({"role": "model", "parts": [{"text": response_text}]})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
st.session_state["chat_history"] = chat_history
|
54 |
|
|
|
49 |
response_text = response.text
|
50 |
|
51 |
chat_history.append({"role": "model", "parts": [{"text": response_text}]})
|
52 |
+
|
53 |
+
if st.button("Display History"):
|
54 |
+
c.execute("SELECT * FROM history")
|
55 |
+
rows = c.fetchall()
|
56 |
+
|
57 |
+
for row in rows:
|
58 |
+
st.markdown(f"**{row[0].title()}:** {row[1]}")
|
59 |
+
|
60 |
+
# Save chat history to database
|
61 |
+
for message in chat_history:
|
62 |
+
c.execute("INSERT INTO history VALUES (?, ?)",
|
63 |
+
(message["role"], message["parts"][0]["text"]))
|
64 |
+
conn.commit()
|
65 |
|
66 |
st.session_state["chat_history"] = chat_history
|
67 |
|