Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import streamlit as st
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
|
| 4 |
# Header for the Streamlit app
|
| 5 |
-
st.header("
|
| 6 |
|
| 7 |
# Retrieve the API key from Streamlit secrets
|
| 8 |
GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]
|
|
@@ -10,24 +10,22 @@ GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]
|
|
| 10 |
# Configure the Google Generative AI API with your API key
|
| 11 |
genai.configure(api_key=GOOGLE_API_KEY)
|
| 12 |
|
| 13 |
-
# Text input for
|
| 14 |
-
user_input = st.text_area("Enter
|
| 15 |
|
| 16 |
-
# Button to submit the
|
| 17 |
-
if st.button("
|
| 18 |
if user_input:
|
|
|
|
|
|
|
| 19 |
try:
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
response = genai.generate_content(model="models/gemini-1.5-bison", prompt=prompt)
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
# Display the extracted keywords
|
| 28 |
-
st.write("Top Keywords:")
|
| 29 |
-
st.write(keywords)
|
| 30 |
except Exception as e:
|
| 31 |
st.error(f"Error: {e}")
|
| 32 |
else:
|
| 33 |
-
st.error("Please enter a
|
|
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
|
| 4 |
# Header for the Streamlit app
|
| 5 |
+
st.header("Google Gemini - Generate Content")
|
| 6 |
|
| 7 |
# Retrieve the API key from Streamlit secrets
|
| 8 |
GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]
|
|
|
|
| 10 |
# Configure the Google Generative AI API with your API key
|
| 11 |
genai.configure(api_key=GOOGLE_API_KEY)
|
| 12 |
|
| 13 |
+
# Text input for user prompt
|
| 14 |
+
user_input = st.text_area("Enter your prompt to generate content:")
|
| 15 |
|
| 16 |
+
# Button to submit the prompt
|
| 17 |
+
if st.button("Generate"):
|
| 18 |
if user_input:
|
| 19 |
+
# Initialize the model
|
| 20 |
+
model = genai.GenerativeModel('gemini-pro') # Assuming this is the correct model
|
| 21 |
try:
|
| 22 |
+
# Generate content based on the user's input
|
| 23 |
+
response = model.generate_content(user_input)
|
|
|
|
| 24 |
|
| 25 |
+
# Display the generated content
|
| 26 |
+
st.write("Generated Content:")
|
| 27 |
+
st.write(response.text)
|
|
|
|
|
|
|
|
|
|
| 28 |
except Exception as e:
|
| 29 |
st.error(f"Error: {e}")
|
| 30 |
else:
|
| 31 |
+
st.error("Please enter a prompt.")
|