Srish117 commited on
Commit
4cdcced
·
verified ·
1 Parent(s): 66cee1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -21,7 +21,7 @@ def get_data(product_name):
21
 
22
  # Filter products with names and return top 5
23
  data['products'] = [p for p in data['products'] if 'product_name' in p]
24
- return data['products'][:5]
25
 
26
  # Function to generate product analysis using Gemini
27
  def generate_summary(product, tone):
@@ -161,25 +161,33 @@ def main():
161
  if not products:
162
  st.error("No products found for the given name.")
163
  else:
164
- product_names = [f"{p['product_name']} (Brand: {p.get('brands', 'Unknown')})" for p in products]
165
- selected_product_name = st.radio("Select a Product", product_names, key='product_selection')
166
- print(selected_product_name)
 
 
 
167
 
168
- selected_product = next(p for p in products if f"{p['product_name']} (Brand: {p.get('brands', 'Unknown')})" == selected_product_name)
169
- print(selected_product)
170
 
171
- st.write(f"### Product Selected: {selected_product['product_name']} (Brand: {selected_product.get('brands', 'Unknown')})")
 
 
172
 
173
- if selected_product:
174
- if 'summary' not in st.session_state:
175
- st.session_state.summary = None
176
 
177
- with st.spinner("Generating AI-powered analysis..."):
 
 
 
 
178
  summary = generate_summary(selected_product, tone.lower())
179
  st.session_state.summary = summary
180
 
181
  st.write("### Product Analysis Summary:")
182
- st.success(st.session_state.summary)
183
 
184
 
185
  # Footer with hackathon and design details
 
21
 
22
  # Filter products with names and return top 5
23
  data['products'] = [p for p in data['products'] if 'product_name' in p]
24
+ return data['products'][:1]
25
 
26
  # Function to generate product analysis using Gemini
27
  def generate_summary(product, tone):
 
161
  if not products:
162
  st.error("No products found for the given name.")
163
  else:
164
+ # product_names = [f"{p['product_name']} (Brand: {p.get('brands', 'Unknown')})" for p in products]
165
+ # selected_product_name = st.radio("Select a Product", product_names, key='product_selection')
166
+ # print(selected_product_name)
167
+
168
+ # selected_product = next(p for p in products if f"{p['product_name']} (Brand: {p.get('brands', 'Unknown')})" == selected_product_name)
169
+ # print(selected_product)
170
 
171
+ # st.write(f"### Product Selected: {selected_product['product_name']} (Brand: {selected_product.get('brands', 'Unknown')})")
 
172
 
173
+ # if selected_product:
174
+ # if 'summary' not in st.session_state:
175
+ # st.session_state.summary = None
176
 
177
+ # with st.spinner("Generating AI-powered analysis..."):
178
+ # summary = generate_summary(selected_product, tone.lower())
179
+ # st.session_state.summary = summary
180
 
181
+ # st.write("### Product Analysis Summary:")
182
+ # st.success(st.session_state.summary)
183
+ product_names = [f"{p['product_name']} (Brand: {p.get('brands', 'Unknown')})" for p in products]
184
+ st.write(f"### Product Selected: {product_names[0]}")
185
+ with st.spinner("Generating AI-powered analysis..."):
186
  summary = generate_summary(selected_product, tone.lower())
187
  st.session_state.summary = summary
188
 
189
  st.write("### Product Analysis Summary:")
190
+
191
 
192
 
193
  # Footer with hackathon and design details