Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,24 +107,30 @@ async def predict_image_and_nutrition(file: UploadFile = File(...)):
|
|
| 107 |
|
| 108 |
# Use the prediction to generate nutrition information
|
| 109 |
# prompt = f"Nutrition information (Calories, Protein, Carbohydrates, Dietary Fiber, Sugars, Fat, Sodium, Potassium, Vitamin C, Vitamin B6, Folate, Niacin, Pantothenic acid) for {prediction} in formatted list"
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
-
|
| 113 |
|
| 114 |
-
|
| 115 |
-
nutrition_info = call_llm(llm_client, nutrition_prompt)
|
| 116 |
-
|
| 117 |
-
# Second prompt: Health benefits and tips
|
| 118 |
-
health_benefits_prompt = f"Provide the health benefits and considerations for {prediction} and give tips for making it healthier."
|
| 119 |
-
health_benefits_and_tips = call_llm(llm_client, health_benefits_prompt)
|
| 120 |
-
|
| 121 |
-
return {
|
| 122 |
-
"predicted_label": prediction,
|
| 123 |
-
"nutrition_info": nutrition_info,
|
| 124 |
-
"health_benefits_and_tips": health_benefits_and_tips
|
| 125 |
-
}
|
| 126 |
except Exception as e:
|
| 127 |
return JSONResponse(
|
| 128 |
status_code=500,
|
| 129 |
content={"error": f"An error occurred: {str(e)}"}
|
| 130 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
# Use the prediction to generate nutrition information
|
| 109 |
# prompt = f"Nutrition information (Calories, Protein, Carbohydrates, Dietary Fiber, Sugars, Fat, Sodium, Potassium, Vitamin C, Vitamin B6, Folate, Niacin, Pantothenic acid) for {prediction} in formatted list"
|
| 110 |
+
prompt = f"Provide all the nutrition information for {prediction}, including Calories, Protein, Carbohydrates, Dietary Fiber, Sugars, Fat, Sodium, Potassium, Vitamin C, Vitamin B6, Folate, Niacin, and Pantothenic acid. Please present the information in a clear, formatted list only, without additional explanations."
|
| 111 |
+
response = call_llm(llm_client, prompt)
|
| 112 |
|
| 113 |
+
return {"predicted_label": prediction, "nutrition_info": response}
|
| 114 |
|
| 115 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
except Exception as e:
|
| 117 |
return JSONResponse(
|
| 118 |
status_code=500,
|
| 119 |
content={"error": f"An error occurred: {str(e)}"}
|
| 120 |
)
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
#nutrition_prompt = f"Provide the nutrition information (Calories, Protein, Carbohydrates, Dietary Fiber, Sugars, Fat, Sodium, Potassium, Vitamin C, Vitamin B6, Folate, Niacin, Pantothenic acid) for {prediction} in a formatted list only."
|
| 126 |
+
# nutrition_info = call_llm(llm_client, nutrition_prompt)
|
| 127 |
+
|
| 128 |
+
# # Second prompt: Health benefits and tips
|
| 129 |
+
# health_benefits_prompt = f"Provide the health benefits and considerations for {prediction} and give tips for making it healthier."
|
| 130 |
+
# health_benefits_and_tips = call_llm(llm_client, health_benefits_prompt)
|
| 131 |
+
|
| 132 |
+
# return {
|
| 133 |
+
# "predicted_label": prediction,
|
| 134 |
+
# "nutrition_info": nutrition_info,
|
| 135 |
+
# "health_benefits_and_tips": health_benefits_and_tips
|
| 136 |
+
# }
|