Spaces:
Sleeping
Sleeping
Leonardo Parente
commited on
Commit
β’
a5534b5
1
Parent(s):
2ad92e3
Add langchain
Browse files- app.py +13 -3
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,9 +1,19 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
st.title("πͺ©π€")
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
|
7 |
if prompt := st.chat_input("Ask something"):
|
8 |
-
st.
|
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
|