shivanis14 commited on
Commit
046807c
1 Parent(s): 4582f56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -277,7 +277,7 @@ def analyze_claims(claims, assistant_id):
277
 
278
  return claims_analysis_str
279
 
280
- def generate_final_analysis(product_info, processing_level, harmful_ingredient_analysis, claims_analysis):
281
  global debug_mode
282
  system_prompt = """You are provided with a detailed analysis of a food product. Your task is to generate actionable insights to help the user decide whether to consume the product, at what frequency, and identify any potential harms or benefits. Consider the context of consumption to ensure the advice is personalized and practical.
283
 
@@ -307,7 +307,7 @@ Additionally, consider the following while generating insights:
307
  - Highlight any risks or benefits at that level of consumption."""
308
 
309
  user_prompt = f"""
310
- Product Name: {product_info['brandName']} {product_info['productName']}
311
 
312
  Processing Level:
313
  {processing_level}
@@ -368,7 +368,7 @@ def main():
368
 
369
  if len(image_links_list) > 0:
370
  product_info_from_db = json.loads(extract_data_from_product_image(image_links_list, data_extractor_url))
371
- print(f"DEBUG : product_info_from_db : {product_info_from_db}")
372
  if product_info_from_db:
373
  try:
374
  brand_name = product_info_from_db["brandName"]
@@ -404,7 +404,8 @@ def main():
404
  # Generate final analysis
405
  if processing_level != "" or harmful_ingredient_analysis != "" or claims_analysis != "":
406
  final_analysis = generate_final_analysis(
407
- product_info,
 
408
  processing_level,
409
  harmful_ingredient_analysis,
410
  claims_analysis
 
277
 
278
  return claims_analysis_str
279
 
280
+ def generate_final_analysis(brand_name, product_name, processing_level, harmful_ingredient_analysis, claims_analysis):
281
  global debug_mode
282
  system_prompt = """You are provided with a detailed analysis of a food product. Your task is to generate actionable insights to help the user decide whether to consume the product, at what frequency, and identify any potential harms or benefits. Consider the context of consumption to ensure the advice is personalized and practical.
283
 
 
307
  - Highlight any risks or benefits at that level of consumption."""
308
 
309
  user_prompt = f"""
310
+ Product Name: {brand_name} {product_name}
311
 
312
  Processing Level:
313
  {processing_level}
 
368
 
369
  if len(image_links_list) > 0:
370
  product_info_from_db = json.loads(extract_data_from_product_image(image_links_list, data_extractor_url))
371
+ print(f"DEBUG : product_info_from_db : {product_info_from_db}\n\n")
372
  if product_info_from_db:
373
  try:
374
  brand_name = product_info_from_db["brandName"]
 
404
  # Generate final analysis
405
  if processing_level != "" or harmful_ingredient_analysis != "" or claims_analysis != "":
406
  final_analysis = generate_final_analysis(
407
+ brand_name,
408
+ product_name,
409
  processing_level,
410
  harmful_ingredient_analysis,
411
  claims_analysis