Spaces:
Running
Running
Commit
Β·
3e275fd
1
Parent(s):
b827b4c
Update page1.py
Browse files
page1.py
CHANGED
@@ -6,8 +6,10 @@ from langchain.prompts import PromptTemplate
|
|
6 |
from langchain.memory import ConversationBufferMemory
|
7 |
from langchain.memory.chat_message_histories import StreamlitChatMessageHistory
|
8 |
from streamlit_chat import message
|
|
|
9 |
def text():
|
10 |
-
|
|
|
11 |
apiKey = "AIzaSyAXkkcrrUBjPEgj93tZ9azy7zcS1wI1jUA"
|
12 |
msgs = StreamlitChatMessageHistory(key="special_app_key")
|
13 |
|
@@ -30,8 +32,7 @@ def text():
|
|
30 |
st.markdown(message["content"])
|
31 |
|
32 |
prompt = st.chat_input("Say something")
|
33 |
-
|
34 |
-
st.write("Hello π, how may I assist you today?")
|
35 |
if prompt:
|
36 |
with st.chat_message("user").markdown(prompt):
|
37 |
st.session_state.messages.append(
|
@@ -40,8 +41,11 @@ def text():
|
|
40 |
"content": prompt
|
41 |
}
|
42 |
)
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
45 |
|
46 |
with st.chat_message("assistant").markdown(text_output):
|
47 |
st.session_state.messages.append(
|
@@ -49,9 +53,4 @@ def text():
|
|
49 |
"role": "assistant",
|
50 |
"content": text_output
|
51 |
}
|
52 |
-
)
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
6 |
from langchain.memory import ConversationBufferMemory
|
7 |
from langchain.memory.chat_message_histories import StreamlitChatMessageHistory
|
8 |
from streamlit_chat import message
|
9 |
+
import time
|
10 |
def text():
|
11 |
+
with st.chat_message("assistant"):
|
12 |
+
st.write("Hello π, how may I assist you today?")
|
13 |
apiKey = "AIzaSyAXkkcrrUBjPEgj93tZ9azy7zcS1wI1jUA"
|
14 |
msgs = StreamlitChatMessageHistory(key="special_app_key")
|
15 |
|
|
|
32 |
st.markdown(message["content"])
|
33 |
|
34 |
prompt = st.chat_input("Say something")
|
35 |
+
|
|
|
36 |
if prompt:
|
37 |
with st.chat_message("user").markdown(prompt):
|
38 |
st.session_state.messages.append(
|
|
|
41 |
"content": prompt
|
42 |
}
|
43 |
)
|
44 |
+
|
45 |
+
with st.spinner('Generating...'):
|
46 |
+
for chunk in llm_chain.stream(prompt):
|
47 |
+
text_output = chunk.get("text", "")
|
48 |
+
|
49 |
|
50 |
with st.chat_message("assistant").markdown(text_output):
|
51 |
st.session_state.messages.append(
|
|
|
53 |
"role": "assistant",
|
54 |
"content": text_output
|
55 |
}
|
56 |
+
)
|
|
|
|
|
|
|
|
|
|