Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,14 +44,28 @@ if product_name and product_features and target_audience:
|
|
| 44 |
Product Features: {product_features}
|
| 45 |
Target Audience: {target_audience}
|
| 46 |
"""
|
|
|
|
| 47 |
if st.button("Generate"):
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
else:
|
| 54 |
-
st.
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
# Add some space or content in between
|
|
|
|
| 44 |
Product Features: {product_features}
|
| 45 |
Target Audience: {target_audience}
|
| 46 |
"""
|
| 47 |
+
# Button to submit the prompt
|
| 48 |
if st.button("Generate"):
|
| 49 |
+
if product_name and product_features and target_audience:
|
| 50 |
+
try:
|
| 51 |
+
# Initialize the generative model (assuming this is the correct model)
|
| 52 |
+
model = genai.GenerativeModel('gemini-pro') # Adjust the model if needed
|
| 53 |
+
|
| 54 |
+
# Generate content based on the prompt
|
| 55 |
+
response = model.generate_content(prompt)
|
| 56 |
+
|
| 57 |
+
# Check if there is a response from the model
|
| 58 |
+
if response:
|
| 59 |
+
st.subheader("Generated Product Description:")
|
| 60 |
+
st.write(response.text) # Displaying the text from the response
|
| 61 |
+
else:
|
| 62 |
+
st.error("Error: Unable to generate the description.")
|
| 63 |
+
|
| 64 |
+
except Exception as e:
|
| 65 |
+
st.error(f"Error: {e}")
|
| 66 |
else:
|
| 67 |
+
st.error("Please fill in all the product details to generate a description.")
|
| 68 |
+
|
| 69 |
|
| 70 |
|
| 71 |
# Add some space or content in between
|