Spaces:
Sleeping
Sleeping
Commit ·
1a73972
1
Parent(s): 8661421
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,37 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
-
from langchain.llms import GooglePalm
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
#x = st.slider('Select a value')
|
| 7 |
-
#st.write(x, 'squared is', x * x)
|
| 8 |
|
| 9 |
-
#pipe = pipeline('sentiment-analysis')
|
| 10 |
|
| 11 |
-
api_key = os.environ["GOOGLE_PALM_API_KEY"]
|
| 12 |
-
llm = GooglePalm(google_api_key=api_key, temperature=0.1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
text = st.text_area('enter text to get assistance!')
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
if text:
|
| 17 |
-
out = llm(text)
|
|
|
|
| 18 |
st.json(out)
|
| 19 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
+
# from langchain.llms import GooglePalm
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
# #x = st.slider('Select a value')
|
| 7 |
+
# #st.write(x, 'squared is', x * x)
|
| 8 |
|
| 9 |
+
# #pipe = pipeline('sentiment-analysis')
|
| 10 |
|
| 11 |
+
# api_key = os.environ["GOOGLE_PALM_API_KEY"]
|
| 12 |
+
# llm = GooglePalm(google_api_key=api_key, temperature=0.1)
|
| 13 |
+
|
| 14 |
+
import google.generativeai as palm
|
| 15 |
+
import os
|
| 16 |
+
|
| 17 |
+
google_api_key=os.getenv('GOOGLE_PALM_API_KEY')
|
| 18 |
+
palm.configure(api_key=google_api_key)
|
| 19 |
|
| 20 |
text = st.text_area('enter text to get assistance!')
|
| 21 |
|
| 22 |
+
#prompt = 'Explain the difference between effective and affective with examples'
|
| 23 |
+
prompt = text
|
| 24 |
+
|
| 25 |
+
completion = palm.generate_text(
|
| 26 |
+
model='models/text-bison-001',
|
| 27 |
+
prompt=prompt,
|
| 28 |
+
temperature=0.1
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
#print(completion.result)
|
| 32 |
+
|
| 33 |
if text:
|
| 34 |
+
#out = llm(text)
|
| 35 |
+
out = completion.result;
|
| 36 |
st.json(out)
|
| 37 |
|