shivanis14
commited on
Commit
•
ec20771
1
Parent(s):
134c5ca
Update app.py
Browse files
app.py
CHANGED
@@ -281,64 +281,47 @@ Claims Analysis:
|
|
281 |
def main():
|
282 |
st.title("Food Product Analysis Chatbot")
|
283 |
|
284 |
-
#
|
285 |
-
|
286 |
-
st.
|
287 |
-
st.
|
288 |
-
st.
|
289 |
-
st.
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
processing_level = analyze_processing_level(st.session_state.ingredients, assistant1)
|
322 |
-
harmful_ingredient_analysis = analyze_harmful_ingredients(st.session_state.ingredients, assistant2)
|
323 |
-
claims_analysis = analyze_claims(st.session_state.claims, assistant3)
|
324 |
-
|
325 |
-
# Generate final analysis
|
326 |
-
final_analysis = generate_final_analysis(
|
327 |
-
st.session_state.product_info,
|
328 |
-
processing_level,
|
329 |
-
harmful_ingredient_analysis,
|
330 |
-
claims_analysis
|
331 |
-
)
|
332 |
-
|
333 |
-
st.write("Analysis complete!")
|
334 |
-
st.write("Final Analysis:")
|
335 |
st.write(final_analysis)
|
336 |
-
|
|
|
337 |
if st.button("Analyze Another Product"):
|
338 |
-
st.session_state.state = 'ingredients'
|
339 |
-
st.session_state.ingredients = []
|
340 |
-
st.session_state.claims = []
|
341 |
-
st.session_state.product_info = {}
|
342 |
st.rerun()
|
343 |
|
344 |
if __name__ == "__main__":
|
|
|
281 |
def main():
|
282 |
st.title("Food Product Analysis Chatbot")
|
283 |
|
284 |
+
# Create a form for all inputs
|
285 |
+
with st.form("product_analysis_form"):
|
286 |
+
st.write("Please enter the following information about the product:")
|
287 |
+
brand_name = st.text_input("Brand Name")
|
288 |
+
product_name = st.text_input("Product Name")
|
289 |
+
ingredients = st.text_area("Ingredients (separated by commas)")
|
290 |
+
claims = st.text_area("Product Claims (separated by commas)")
|
291 |
+
|
292 |
+
submitted = st.form_submit_button("Analyze Product")
|
293 |
+
|
294 |
+
if submitted:
|
295 |
+
# Process inputs
|
296 |
+
ingredients_list = [ingredient.strip() for ingredient in ingredients.split(',')]
|
297 |
+
claims_list = [claim.strip() for claim in claims.split(',')]
|
298 |
+
product_info = {
|
299 |
+
"brandName": brand_name,
|
300 |
+
"productName": product_name
|
301 |
+
}
|
302 |
+
|
303 |
+
# Display a message while analyzing
|
304 |
+
with st.spinner("Analyzing the product... This may take a moment."):
|
305 |
+
# Perform analysis
|
306 |
+
processing_level = analyze_processing_level(ingredients_list, assistant1.id)
|
307 |
+
harmful_ingredient_analysis = analyze_harmful_ingredients(ingredients_list, assistant2.id)
|
308 |
+
claims_analysis = analyze_claims(claims_list, assistant3.id)
|
309 |
+
|
310 |
+
# Generate final analysis
|
311 |
+
final_analysis = generate_final_analysis(
|
312 |
+
product_info,
|
313 |
+
processing_level,
|
314 |
+
harmful_ingredient_analysis,
|
315 |
+
claims_analysis
|
316 |
+
)
|
317 |
+
|
318 |
+
# Display results
|
319 |
+
st.success("Analysis complete!")
|
320 |
+
st.subheader("Final Analysis:")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
st.write(final_analysis)
|
322 |
+
|
323 |
+
# Option to start over
|
324 |
if st.button("Analyze Another Product"):
|
|
|
|
|
|
|
|
|
325 |
st.rerun()
|
326 |
|
327 |
if __name__ == "__main__":
|