jonathanjordan21 commited on
Commit
82aedcc
1 Parent(s): c80fe35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -24
app.py CHANGED
@@ -83,27 +83,4 @@ if prompt := st.chat_input("Ask me anything.."):
83
  st.session_state.memory.save_context({"question":prompt}, {"output":response})
84
  st.session_state.memory.chat_memory.messages = st.session_state.memory.chat_memory.messages[-15:]
85
  # Add assistant response to chat history
86
- st.session_state.messages.append({"role": "assistant", "content": response})
87
-
88
- # Insert data into the table
89
- try :
90
- try :
91
- cur = st.session_state.conn.cursor()
92
- except:
93
- get_db_connection.clear()
94
- st.session_state.conn = get_db_connection(POSTGRE_URL)
95
- cur = st.session_state.conn.cursor()
96
-
97
- cur.execute(
98
- f"INSERT INTO chat_history (input_text, response_text, created_at) VALUES (%s, %s, %s)",
99
- (prompt, response, datetime.now(timezone.utc) + timedelta(hours=7))
100
- )
101
-
102
- # Commit the transaction
103
- st.session_state.conn.commit()
104
- cur.close()
105
- except Exception as e:
106
- print("ERROR!!!\n", str(e))
107
- print("User Input :", prompt)
108
- print("Chatbot Response :", response)
109
-
 
83
  st.session_state.memory.save_context({"question":prompt}, {"output":response})
84
  st.session_state.memory.chat_memory.messages = st.session_state.memory.chat_memory.messages[-15:]
85
  # Add assistant response to chat history
86
+ st.session_state.messages.append({"role": "assistant", "content": response})