Spaces:
Runtime error
Runtime error
feat: try palm2
Browse files
app.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import random
|
3 |
import time
|
|
|
4 |
|
5 |
-
|
|
|
|
|
6 |
|
7 |
# Initialize chat history
|
8 |
if "messages" not in st.session_state:
|
@@ -25,13 +29,7 @@ if prompt := st.chat_input("What is up?"):
|
|
25 |
with st.chat_message("assistant"):
|
26 |
message_placeholder = st.empty()
|
27 |
full_response = ""
|
28 |
-
assistant_response =
|
29 |
-
[
|
30 |
-
"Hello there! How can I assist you today?",
|
31 |
-
"Hi, human! Is there anything I can help you with?",
|
32 |
-
"Do you need help?",
|
33 |
-
]
|
34 |
-
)
|
35 |
# Simulate stream of response with milliseconds delay
|
36 |
for chunk in assistant_response.split():
|
37 |
full_response += chunk + " "
|
|
|
1 |
import streamlit as st
|
2 |
+
import google.generativeai as palm
|
3 |
import random
|
4 |
import time
|
5 |
+
import os
|
6 |
|
7 |
+
palm.configure(api_key=os.environ.get('API_Key'))
|
8 |
+
|
9 |
+
st.title("PaLM2 Chat")
|
10 |
|
11 |
# Initialize chat history
|
12 |
if "messages" not in st.session_state:
|
|
|
29 |
with st.chat_message("assistant"):
|
30 |
message_placeholder = st.empty()
|
31 |
full_response = ""
|
32 |
+
assistant_response = palm.chat(messages=[prompt]).last
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
# Simulate stream of response with milliseconds delay
|
34 |
for chunk in assistant_response.split():
|
35 |
full_response += chunk + " "
|