jonathanjordan21 commited on
Commit
3d00f79
1 Parent(s): 4ed8fad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -55,8 +55,8 @@ def get_db_connection(conn_url, password=None):
55
  if 'conn' not in st.session_state:
56
  st.session_state.conn = get_db_connection(POSTGRE_URL)
57
 
58
- if 'cursor' not in st.session_state:
59
- st.session_state.cursor = st.session_state.conn.cursor()
60
 
61
  if 'memory' not in st.session_state:
62
  st.session_state['memory'] = ConversationBufferMemory(return_messages=True)
@@ -112,7 +112,7 @@ 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
- st.session_state.cursor.execute(
116
  "INSERT INTO chat_history (input_text, response_text, created_at) VALUES (%s, %s, %s)",
117
  (prompt, response, datetime.now(timezone.utc) + timedelta(hours=7))
118
  )
 
55
  if 'conn' not in st.session_state:
56
  st.session_state.conn = get_db_connection(POSTGRE_URL)
57
 
58
+ # if 'cursor' not in st.session_state:
59
+ # st.session_state.cursor = st.session_state.conn.cursor()
60
 
61
  if 'memory' not in st.session_state:
62
  st.session_state['memory'] = ConversationBufferMemory(return_messages=True)
 
112
  st.session_state.messages.append({"role": "assistant", "content": response})
113
 
114
  # Insert data into the table
115
+ st.session_state.conn.cursor().execute(
116
  "INSERT INTO chat_history (input_text, response_text, created_at) VALUES (%s, %s, %s)",
117
  (prompt, response, datetime.now(timezone.utc) + timedelta(hours=7))
118
  )