shivanis14 commited on
Commit
99b346f
1 Parent(s): 178580d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -58,12 +58,12 @@ def find_product_type(product_info_from_db):
58
 
59
 
60
  product_type = None
61
- calories = -1
62
- sugar = -1
63
- total_sugar = -1
64
- added_sugar = -1
65
- salt = -1
66
- serving_size = -1
67
 
68
  if product_info_from_db["servingSize"]["unit"] == "g":
69
  product_type = "solid"
@@ -82,11 +82,12 @@ def find_product_type(product_info_from_db):
82
  sugar = item['values'][0]['value']
83
 
84
  #How to get Salt?
85
- if added_sugar > 0 and sugar == -1:
86
  sugar = added_sugar
87
- elif total_sugar > 0 and added_sugar == -1 and sugar == -1:
88
  sugar = total_sugar
89
  return product_type, calories, sugar, salt, serving_size
 
90
  # Initialize assistants and vector stores
91
  # Function to initialize vector stores and assistants
92
  @st.cache_resource
@@ -389,6 +390,7 @@ def analyze_product(product_info_raw, system_prompt):
389
  if len(ingredients_list) > 0:
390
  product_type, calories, sugar, salt, serving_size = find_product_type(product_info_from_db)
391
  nutrient_analysis = analyze_nutrients(product_type, calories, sugar, salt, serving_size)
 
392
  processing_level = analyze_processing_level(ingredients_list, brand_name, product_name, assistant1.id) if ingredients_list else ""
393
  harmful_ingredient_analysis = analyze_harmful_ingredients(ingredients_list, brand_name, product_name, assistant2.id) if ingredients_list else ""
394
  if len(claims_list) > 0:
 
58
 
59
 
60
  product_type = None
61
+ calories = None
62
+ sugar = None
63
+ total_sugar = None
64
+ added_sugar = None
65
+ salt = None
66
+ serving_size = None
67
 
68
  if product_info_from_db["servingSize"]["unit"] == "g":
69
  product_type = "solid"
 
82
  sugar = item['values'][0]['value']
83
 
84
  #How to get Salt?
85
+ if added_sugar > 0 and sugar is None:
86
  sugar = added_sugar
87
+ elif total_sugar > 0 and added_sugar is None and sugar is None:
88
  sugar = total_sugar
89
  return product_type, calories, sugar, salt, serving_size
90
+
91
  # Initialize assistants and vector stores
92
  # Function to initialize vector stores and assistants
93
  @st.cache_resource
 
390
  if len(ingredients_list) > 0:
391
  product_type, calories, sugar, salt, serving_size = find_product_type(product_info_from_db)
392
  nutrient_analysis = analyze_nutrients(product_type, calories, sugar, salt, serving_size)
393
+ print(f"nutrient analysis is {nutrient_analysis}")
394
  processing_level = analyze_processing_level(ingredients_list, brand_name, product_name, assistant1.id) if ingredients_list else ""
395
  harmful_ingredient_analysis = analyze_harmful_ingredients(ingredients_list, brand_name, product_name, assistant2.id) if ingredients_list else ""
396
  if len(claims_list) > 0: