gnumanth commited on
Commit
ad3d299
1 Parent(s): eeb5d1d

feat: try palm2

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -1,8 +1,12 @@
1
  import streamlit as st
 
2
  import random
3
  import time
 
4
 
5
- st.title("Simple chat")
 
 
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 = random.choice(
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 + " "