shivanis14 commited on
Commit
3f200b0
1 Parent(s): 79eb04b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -295,8 +295,6 @@ Fat & Calories: Offer practical context for these nutrients, explaining the impl
295
  Ensure the response is clear, accurate, and provides actionable recommendations for healthier choices."""
296
 
297
  user_prompt = f"""
298
- Product Name: {brand_name} {product_name}
299
-
300
  Nutrition Analysis :
301
  {nutrient_analysis}
302
  {nutrient_analysis_rda}
@@ -314,7 +312,7 @@ Nutrition Analysis :
314
 
315
  return completion.choices[0].message.content
316
 
317
- def analyze_processing_level(ingredients, brand_name, product_name, assistant_id):
318
  global debug_mode, client
319
  thread = client.beta.threads.create(
320
  messages=[
@@ -347,7 +345,7 @@ def analyze_processing_level(ingredients, brand_name, product_name, assistant_id
347
  processing_level_str = message_content.value
348
  return processing_level_str
349
 
350
- def analyze_harmful_ingredients(ingredients, brand_name, product_name, assistant_id):
351
  global debug_mode, client
352
  thread = client.beta.threads.create(
353
  messages=[
@@ -392,7 +390,7 @@ def analyze_harmful_ingredients(ingredients, brand_name, product_name, assistant
392
  harmful_ingredient_analysis_str += f"{key}: {value}\n"
393
  return harmful_ingredient_analysis_str
394
 
395
- def analyze_claims(claims, ingredients, product_name, assistant_id):
396
  global debug_mode, client
397
  thread = client.beta.threads.create(
398
  messages=[
@@ -529,11 +527,11 @@ def analyze_product(product_info_raw, system_prompt):
529
  nutritional_level = analyze_nutrition_icmr_rda(nutrient_analysis, nutrient_analysis_rda)
530
 
531
  if len(ingredients_list) > 0:
532
- processing_level = analyze_processing_level(ingredients_list, brand_name, product_name, assistant1.id) if ingredients_list else ""
533
- harmful_ingredient_analysis = analyze_harmful_ingredients(ingredients_list, brand_name, product_name, assistant2.id) if ingredients_list else ""
534
 
535
  if len(claims_list) > 0:
536
- claims_analysis = analyze_claims(claims_list, ingredients_list, product_name, assistant3.id) if claims_list else ""
537
 
538
  final_analysis = generate_final_analysis(brand_name, product_name, nutritional_level, processing_level, harmful_ingredient_analysis, claims_analysis, system_prompt)
539
  return final_analysis
 
295
  Ensure the response is clear, accurate, and provides actionable recommendations for healthier choices."""
296
 
297
  user_prompt = f"""
 
 
298
  Nutrition Analysis :
299
  {nutrient_analysis}
300
  {nutrient_analysis_rda}
 
312
 
313
  return completion.choices[0].message.content
314
 
315
+ def analyze_processing_level(ingredients, assistant_id):
316
  global debug_mode, client
317
  thread = client.beta.threads.create(
318
  messages=[
 
345
  processing_level_str = message_content.value
346
  return processing_level_str
347
 
348
+ def analyze_harmful_ingredients(ingredients, assistant_id):
349
  global debug_mode, client
350
  thread = client.beta.threads.create(
351
  messages=[
 
390
  harmful_ingredient_analysis_str += f"{key}: {value}\n"
391
  return harmful_ingredient_analysis_str
392
 
393
+ def analyze_claims(claims, ingredients, assistant_id):
394
  global debug_mode, client
395
  thread = client.beta.threads.create(
396
  messages=[
 
527
  nutritional_level = analyze_nutrition_icmr_rda(nutrient_analysis, nutrient_analysis_rda)
528
 
529
  if len(ingredients_list) > 0:
530
+ processing_level = analyze_processing_level(ingredients_list, assistant1.id) if ingredients_list else ""
531
+ harmful_ingredient_analysis = analyze_harmful_ingredients(ingredients_list, assistant2.id) if ingredients_list else ""
532
 
533
  if len(claims_list) > 0:
534
+ claims_analysis = analyze_claims(claims_list, ingredients_list, assistant3.id) if claims_list else ""
535
 
536
  final_analysis = generate_final_analysis(brand_name, product_name, nutritional_level, processing_level, harmful_ingredient_analysis, claims_analysis, system_prompt)
537
  return final_analysis