Leonardo Parente commited on
Commit
a5534b5
β€’
1 Parent(s): 2ad92e3

Add langchain

Browse files
Files changed (2) hide show
  1. app.py +13 -3
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,9 +1,19 @@
1
  import streamlit as st
 
 
 
 
 
2
 
3
  st.title("πŸͺ©πŸ€–")
4
 
5
- st.chat_message("ai").write("Ask me anything about orb community projects!")
 
 
 
 
6
 
7
  if prompt := st.chat_input("Ask something"):
8
- st.write(f"User has sent the following prompt: {prompt}")
9
-
 
 
1
  import streamlit as st
2
+ from langchain.memory import ConversationBufferMemory
3
+ from langchain.memory.chat_message_histories import StreamlitChatMessageHistory
4
+
5
+ msgs = StreamlitChatMessageHistory()
6
+ memory = ConversationBufferMemory(memory_key="history", chat_memory=msgs)
7
 
8
  st.title("πŸͺ©πŸ€–")
9
 
10
+ if len(msgs.messages) == 0:
11
+ msgs.add_ai_message("Ask me anything about orb community projects!")
12
+
13
+ for msg in msgs.messages:
14
+ st.chat_message(msg.type).write(msg.content)
15
 
16
  if prompt := st.chat_input("Ask something"):
17
+ st.chat_message("human").write(prompt)
18
+ # Run
19
+ st.chat_message("ai").write("hehe")
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- langchain
 
 
1
+ langchain
2
+ streamlit