Function Repository Resource:

RecipeAllergenFinder

Source Notebook

Identify potential food allergens in recipes

Contributed by: Gay Wilson

ResourceFunction["RecipeAllergenFinder"][recipe]

identifies and lists potential food allergens in a recipe.

Details and Options

RecipeAllergenFinder 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 RecipeAllergenFinder prompt instructs the LLM to act as a trained dietitian who specializes in food allergies. The LLM reviews recipes for the following allergens and sensitivities ONLY: gluten, milk, eggs, peanuts, tree nuts, soy, wheat, fish, shellfish, sesame, corn, strawberries, monosodium glutamate (MSG) and sulphites.
RecipeAllergenFinder creates a grid of the allergens and the corresponding ingredients in the recipe.
ResourceFunction["RecipeAllergenFinder"] is for general information purposes only. It is not intended as medical advice and should not replace personalized guidance from a physician or registered dietitian, especially for individuals with significant food allergies or intolerances.
ResourceFunction["RecipeAllergenFinder"] supports the option LLMEvaluator and supports the same LLM models as LLMConfiguration.

Examples

Basic Examples (1) 

Give the LLM a stir-fry recipe to assess:

In[1]:=
ResourceFunction["RecipeAllergenFinder"]["Ingredients:
Rice noodles, 8 oz
Olive oil, 2 tbsp
Garlic, 2 cloves, minced
Ginger, 1 tbsp, minced
Assorted vegetables, 3 1/2 cups, chopped
Tofu, 1 lb, sliced
Soy sauce, 3 tbsp
Sesame oil, 1 tsp
Honey, 2 tbsp
Rice vinegar, 1 tbsp
Scallions, 1 tbsp, chopped
Peanuts, 1 tbsp, chopped
Sesame seeds, 1 tsp
Instructions:
Cook the noodles according to directions, then drain and set aside.
Heat 1 tablespoon of olive oil in a large pan or wok over medium-high heat.
Add the tofu and cook until golden brown. Remove from pan and set aside.
In same pan, add remaining olive oil.
Add garlic and ginger, then stir-fry briefly until fragrant.
Add vegetables and stir-fry for 6-8 minutes until slightly tender.
Return tofu to the pan, then add cooked noodles.
In a small bowl, combine soy sauce, sesame oil, honey and rice vinegar, then pour into pan.
Toss together until noodles, vegetables and tofu are coated and heated through.
Serve and garnish with scallions, peanuts and sesame seeds."]
Out[1]=

Scope (1) 

Test the LLM with a recipe that includes gluten-free pasta to see if it correctly excludes the gluten-free ingredient from the allergen output:

In[2]:=
ResourceFunction["RecipeAllergenFinder"]["Ingredients:
12 ounces gluten-free spaghetti
2 tsp salt
3 tbsp olive oil
3 garlic cloves, chopped
1 tsp crushed red pepper
1/2 tbsp fresh thyme
4 tbsp unsalted butter
1 cup pasta water
1 cup freshly grated parmesan
1 lemon, juiced and zested
1/8 tsp black pepper
Topping:
1/2 cup bread crumbs
1/2 tbsp unsalted butter
1/2 tbsp dried thyme
Instructions:
Heat 1/2 tbsp butter in a small pan over medium heat. Add bread crumbs and dried thyme.
Stirring frequently, cook until bread crumbs are golden brown. Set aside.
Cook the gluten-free spaghetti in salted boiling water until al dente.
In a large pan, add the olive oil, garlic, crushed red pepper and fresh thyme on low heat. Stir in butter.
Add pasta water, 3/4 cup grated parmesan and lemon juice. Stir over medium heat.
Add gluten-free spaghetti to the sauce to finish cooking.
Transfer to serving platter, and garnish with black pepper, remaining parmesan, lemon zest and toasted bread crumbs."]
Out[2]=

Options (1) 

Specify the LLM model to use in this beef Stroganoff recipe:

In[3]:=
ResourceFunction["RecipeAllergenFinder"]["Ingredients:
1 lb ribeye steak, trimmed and sliced into thin strips
2 tbsp olive oil
1 medium onion, chopped
2 cloves garlic, minced
8 oz cremini mushrooms, sliced
1/2 cup dry white wine
1 cup beef broth
3/4 cup sour cream
2 tbsp all-purpose flour
1 tbsp Dijon mustard
1 tbsp Worcestershire sauce
1/2 tsp salt
1/4 tsp pepper
1/4 cup fresh parsley, chopped
12 oz wide egg noodles", "Model" -> <|"Service" -> "OpenAI", "Name" -> "GPT-3.5 Turbo"|>]
Out[3]=

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.1.0 – 23 August 2024
  • 1.0.0 – 15 July 2024

Related Resources

License Information