Spaces:
Sleeping
Sleeping
Commit
·
a022260
1
Parent(s):
4186464
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,7 @@ if 'memory' not in st.session_state:
|
|
25 |
# st.session_state['memory'] = ConversationBufferMemory(return_messages=True)
|
26 |
|
27 |
st.session_state.memory = PostgresChatMessageHistory(connection_string=POSTGRE_URL, session_id=str(datetime.timestamp(datetime.now())))
|
|
|
28 |
|
29 |
if 'chain' not in st.session_state:
|
30 |
st.session_state['chain'] = custom_chain_with_history(
|
@@ -57,8 +58,10 @@ if prompt := st.chat_input("Ask me anything.."):
|
|
57 |
# Display assistant response in chat message container
|
58 |
with st.chat_message("assistant"):
|
59 |
st.markdown(response)
|
60 |
-
st.session_state.memory.
|
61 |
-
st.session_state.memory.
|
|
|
|
|
62 |
# Add assistant response to chat history
|
63 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
64 |
|
|
|
25 |
# st.session_state['memory'] = ConversationBufferMemory(return_messages=True)
|
26 |
|
27 |
st.session_state.memory = PostgresChatMessageHistory(connection_string=POSTGRE_URL, session_id=str(datetime.timestamp(datetime.now())))
|
28 |
+
st.session_state.memory.add_ai_message("Hello, My name is Jonathan Jordan. You can call me Jojo. How can I help you today?")
|
29 |
|
30 |
if 'chain' not in st.session_state:
|
31 |
st.session_state['chain'] = custom_chain_with_history(
|
|
|
58 |
# Display assistant response in chat message container
|
59 |
with st.chat_message("assistant"):
|
60 |
st.markdown(response)
|
61 |
+
st.session_state.memory.add_user_message(prompt)
|
62 |
+
st.session_state.memory.add_ai_message(response)
|
63 |
+
# st.session_state.memory.save_context({"question":prompt}, {"output":response})
|
64 |
+
# st.session_state.memory.chat_memory.messages = st.session_state.memory.chat_memory.messages[-15:]
|
65 |
# Add assistant response to chat history
|
66 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
67 |
|