Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -112,7 +112,13 @@ if prompt := st.chat_input("Ask me anything.."):
|
|
112 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
113 |
|
114 |
# Insert data into the table
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
cur.execute(
|
117 |
f"INSERT INTO chat_history (input_text, response_text, created_at) VALUES (%s, %s, %s)",
|
118 |
(prompt, response, datetime.now(timezone.utc) + timedelta(hours=7))
|
|
|
112 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
113 |
|
114 |
# Insert data into the table
|
115 |
+
try :
|
116 |
+
cur = st.session_state.conn.cursor()
|
117 |
+
except:
|
118 |
+
get_db_connection.clear()
|
119 |
+
st.session_state.conn = get_db_connection(POSTGRE_URL)
|
120 |
+
cur = st.session_state.conn.cursor()
|
121 |
+
|
122 |
cur.execute(
|
123 |
f"INSERT INTO chat_history (input_text, response_text, created_at) VALUES (%s, %s, %s)",
|
124 |
(prompt, response, datetime.now(timezone.utc) + timedelta(hours=7))
|