Spaces:
Sleeping
Sleeping
File size: 3,054 Bytes
c182e4e 58905ee c182e4e fec921d c182e4e fec921d 0a1127e e677fdf 0a1127e e677fdf 0a1127e fec921d aea090d c182e4e bccb37f fec921d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
import streamlit as st
import google.generativeai as genai
# Streamlit app layout
st.title('Personalized Product Description Writer')
# Retrieve the API key from Streamlit secrets
GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]
# Configure the Google Generative AI API with your API key
genai.configure(api_key=GOOGLE_API_KEY)
# Input fields for the product details
st.subheader("Enter Product Details:")
product_name = st.text_input('Product Name', '')
product_features = st.text_area('Product Features (comma separated)', '')
target_audience = st.text_input('Target Audience', '')
# Create the prompt based on user inputs
if product_name and product_features and target_audience:
prompt = f"""
Analyze the following product details:
1. Generate a catchy product description:
- Use a tone that resonates with the target audience (e.g., playful for gamers, professional for WFH employees).
- Include a brief brand story or emotional appeal to connect with potential buyers.
- Highlight the product's unique selling points (USP) that differentiate it from competitors.
- Mention specific usage scenarios (e.g., long gaming sessions, remote work).
- End with a strong call to action (e.g., "Level up your comfort today!").
2. Extract key features from the product features provided:
- Identify and list the most important and unique features of the product.
- Explain each feature's benefit to the user.
- Emphasize how these features contribute to a better user experience.
- Organize features in a logical order.
- Include secondary features that add value.
3. Suggest marketing strategies based on the target audience (Indian market):
4. Suggest some frequently asked questions FAQs
Product Name: {product_name}
Product Features: {product_features}
Target Audience: {target_audience}
"""
# Button to submit the prompt
if st.button("Generate"):
if product_name and product_features and target_audience:
try:
# Initialize the generative model (assuming this is the correct model)
model = genai.GenerativeModel('gemini-pro') # Adjust the model if needed
# Generate content based on the prompt
response = model.generate_content(prompt)
# Check if there is a response from the model
if response:
st.subheader("Generated Product Description:")
st.write(response.text) # Displaying the text from the response
else:
st.error("Error: Unable to generate the description.")
except Exception as e:
st.error(f"Error: {e}")
else:
st.error("Please fill in all the product details to generate a description.")
# Add some space or content in between
st.write("\n" * 20) # You can adjust the number of lines to push the content down
# Footer
#st.sidebar.markdown("---")
st.markdown("Built with 🧠 by Hruday & Google Gemini")
|