Function Repository Resource:

RecipeRiskAnalysis

Source Notebook

Identify potential food safety hazards in recipes

Contributed by: Gay Wilson

ResourceFunction["RecipeRiskAnalysis"][recipe]

identifies and highlights potential food safety hazards in a recipe.

Details and Options

RecipeRiskAnalysis relies on a large language model (LLM) and requires an API key.
You can check whether an API Key is set by evaluating SystemCredential["your keyname"]. If needed, the key can be set using SystemCredential["your keyname"]="your-key-here".
The RecipeRiskAnalysis prompt instructs the LLM to act as the food safety manager at a high-profile restaurant and to review new recipes according to the FDA's Hazard Analysis and Critical Control Point (HACCP) guidelines.
HACCP is a systematic approach to the identification, evaluation and control of food safety hazards. An important step in the HACCP process is to identify critical control points (CCPs). These are specific steps in the production or processing of food where control can be applied to prevent, eliminate or reduce food safety hazards.
ResourceFunction["RecipeRiskAnalysis"] supports the option LLMEvaluator and supports the same LLM models as LLMConfiguration.

Examples

Basic Examples (1) 

Give the LLM a roasted pork tenderloin recipe to assess:

In[1]:=
ResourceFunction["RecipeRiskAnalysis"]["Ingredients:
- 1 1/2 lbs pork tenderloin
- 2 Tbsp olive oil
- 3 cloves garlic, minced
- 1 tsp dried thyme
- 1 tsp dried rosemary
- 1 tsp sea salt
- 1/2 tsp pepper

Instructions:
1. Preheat oven to 400 degrees Fahrenheit. 
2. Mix together the minced garlic, dried thyme, dried rosemary, salt and pepper in a small bowl.
3. Rub the olive oil over the tenderloin, then evenly pat the spice mixture onto the pork. Make sure all sides are coated well.
4. Transfer the tenderloin to a roasting pan or a prepared baking dish.
5. Put the tenderloin in the preheated oven and roast for 25-35 minutes until the internal temperature reaches at least 145 degrees Fahrenheit.
6. Remove the tenderloin from the oven and let it rest for 10 minutes before slicing. This allows the juices to redistribute throughout the pork.
7. Slice the tenderloin into thin rounds and serve."]
Out[1]=

Options (1) 

Specify the LLM model for this chicken piccata recipe:

In[2]:=
ResourceFunction["RecipeRiskAnalysis"]["Ingredients:
- 2 boneless, skinless chicken breasts
- 1/4 tsp salt
- 1/8 tsp black pepper
- 1/4 cup all-purpose flour 
- 2 Tbsp olive oil
- 2 Tbsp unsalted butter
- 1 clove garlic, minced
- 1 cup chicken broth
- 2 Tbsp lemon juice
- 1/4 cup capers, drained
- 2 Tbsp fresh parsley, chopped

Instructions:
1. Flatten the chicken breasts with a mallet or rolling pin until they are 1/4 to 1/2-inch thick.
2. Season both sides of the chicken with salt and pepper.
3. Dredge the chicken in the flour to coat lightly on both sides; shake off the excess flour.
4. Heat the olive oil in a large skillet over medium-high heat.
5. Add the chicken and cook for 3-4 minutes on each side, until golden brown and cooked through. Remove the chicken from the pan and set aside.
6. In the same skillet, add the butter and garlic, and sauté about a minute.
7. Add the chicken broth, lemon juice and capers. Bring to a boil, turn down heat, and let simmer until the sauce has reduced.
8. Return the chicken to the skillet and simmer for 2-3 minutes, until the chicken is heated through.
9. Garnish with fresh chopped parsley before serving.", LLMEvaluator -> <|"Service" -> "OpenAI", "Name" -> "GPT-4"|>]
Out[2]=

Neat Examples (2) 

Use the LLM to create the recipe:

In[3]:=
ResourceFunction["RecipeRiskAnalysis"]@
 LLMSynthesize[
  "Write a simple recipe for shrimp scampi. Single space the recipe."]
Out[3]=

Use a chocolate chip cookie recipe to highlight why eating raw cookie dough is not recommended:

In[4]:=
ResourceFunction["RecipeRiskAnalysis"]["Ingredients:
- 2 1/4 cups all-purpose flour
- 1 teaspoon baking soda
- 1 teaspoon salt
- 1 cup (2 sticks) unsalted butter, softened
- 1/2 cup granulated sugar
- 1 cup light brown sugar, packed
- 2 teaspoons vanilla extract
- 2 large eggs
- 2 cups semisweet chocolate chips

Instructions:
1. Preheat oven to 375°F(190°C). Line baking sheets with parchment paper.
2. In a medium bowl, whisk together the flour, baking soda and salt.
3. In a large bowl, beat together the butter, granulated sugar, brown sugar and vanilla until creamy.
4. Add the eggs, one at a time, beating well after each egg.
5. Gradually add the flour mixture until just combined, then stir in the chocolate chips.
6. Drop dough by rounded tablespoons onto the prepared baking sheets, spacing them about 2 inches apart.
7. Bake about 10 minutes, until the edges are golden but the centers are still soft.
8. Allow the cookies to cool briefly on the baking sheets, then transfer to a wire rack to cool completely."]
Out[4]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 2.0.0 – 07 August 2024
  • 1.0.0 – 29 April 2024

Related Resources

License Information