hruday96 commited on
Commit
0a1127e
1 Parent(s): e677fdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -6
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
- # Call to Google Gemini API
49
- response = genai.generate(prompt)
50
- if response:
51
- st.subheader("Generated Product Description:")
52
- st.write(response)
 
 
 
 
 
 
 
 
 
 
 
 
53
  else:
54
- st.write("Error: Unable to generate the description.")
 
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