Skip to content

Repository files navigation

Recipe Template Generator

Description

This program takes recipe and solubility data as inputs and generates recipe templates for a product type based on the functionality of its ingredients and solubility data. The functionality of ingredients is generated by LlamaIndex QA model with documents from top 5 webpages from Google Search results. The output recipe templates include information of product type, functionality, phase, weight proportion range, confidence points range, and source links.

Prerequisites

  • Python 3.9 or higher
  • Pandas 2.0.0 or higher
  • regex 2023.3.23 or higher
  • nltk 3.8.1 or higher
  • google-api-python-client 2.86.0 or higher
  • requests 2.28.2 or higher
  • langchain 0.0.143
  • llama-index 0.5.17
  • beautifulsoup4 4.12.2 or higher The requirements are contained in requirements.txt. We recommend installing them in a new virtual environment. To install them, run
    $ pip install -r requirements.txt

Input File Format

Recipe File

  • Format: .csv
  • Header: File, Product, Phase, Ingredient, Weight, ProductType, ProductSubType, FunctionalityOld
  • Required columns: File, Product, Ingredient, Weight, ProductSubType
  • Note: Weight column should only contain numeric values
  • Example:
File,Product,Phase,Ingredient,Weight,ProductType,ProductSubType,FunctionalityOld
Vol2_1092.txt,FOUNDATION CREAM,A,Lamecreme KSM,20,Cream,Foundation Cream,
Vol2_1092.txt,FOUNDATION CREAM,A,Olive Oil,4,Cream,Foundation Cream,
Vol2_1092.txt,FOUNDATION CREAM,A,Belsil BNP,3,Cream,Foundation Cream,
Vol2_1092.txt,FOUNDATION CREAM,B,Glycerine,4,Cream,Foundation Cream,humectant
Vol2_1092.txt,FOUNDATION CREAM,B,Water,67.5,Cream,Foundation Cream,solvent
Vol2_1092.txt,FOUNDATION CREAM,B,Belsil PDM 20,11,Cream,Foundation Cream,
Vol2_1092.txt,FOUNDATION CREAM,B,Belsil CM 020,0.5,Cream,Foundation Cream,
Vol2_1092.txt,FOUNDATION CREAM,B,"Preservatives, fragrances, pigments",,Cream,Foundation Cream,

Solubility File

  • Format: .xlsx
  • Header: Ingredient, Water Solubility, Oil Solubility, LogP, Remarks
  • Required columns: Ingredient, Water Solubility, Oil Solubility
  • Note: Water Solubility and Oil Solubility columns should only contain string values in the following list:
    • Highly soluble
    • Soluble
    • Slightly soluble
    • less Soluble
    • Varies
    • Unknown
    • N/A
    • Poorly soluble
    • Insoluble
  • Example:
Ingredient Water Solubility Oil Solubility LogP Remarks
Candelilla Wax Insoluble Soluble
Wacker-Belsil SDM 6022 Unknown Unknown water based emulsions, can be mixed with water phase
Stearic Acid Poorly soluble Soluble 7.6
Water Highly soluble Poorly soluble Not soluble
Propylene Glycol Highly soluble less Soluble in oil less soluble

Environent Variables

  • GOOGLE_API_KEY: Your API key for the Google service.
  • GOOGLE_CSE_ID: Your Google Customer Search Engine ID.
  • OPENAI_API_KEY: Your API key for the OpenAI service.

How to get your Google API key and CSE ID?

  1. Set up a Custom Search Engine (CSE) by following these steps:
    i. Go to the Google Programmable Search Engine page.
    ii. Click "Get Started" and follow the instructions to create a new search engine.
    iii. During setup, you can choose to search specific sites or the entire web.
    iv. Once your search engine is created, take note of the Search Engine ID.
  2. Get your API key:
    i. Go to the Google Cloud Console.
    ii. Select or create a project.
    iii. Navigate to the "Credentials" tab and create a new API key.

How to get your OpenAI API key?

  1. Visit https://openai.com/blog/openai-api and click on the ‘Sign Up’ button.
  2. Create your account on Open AI by entering your email and password.
  3. After creating your account, you would have received an email on the registered email address requesting you to verify your email address. Verify your Open AI email by pressing the ‘Verify email address’ button in the email received.
  4. Once you press the ‘Verify email address’ button, your email address would be verified and you will be directed to the ‘Tell us about you’ page where you need to enter your basic information followed by a phone number. You will be required to later verify your phone number.
  5. Once you verify your phone number, you will be directed to Open AI’s platform (https://platform.openai.com/).
  6. On the top right corner, press ‘Personal’ -> ‘View API keys’ -> ‘USER’ -> ‘API keys’ -> ‘+ Create new secret key’.
  7. Enter a name for the secret key if you wish and press ‘Create secret key’. Copy and store the key that is displayed. Usually it starts with ‘sk-’. This key is your Open AI’s API key.

Set environment variables

$ export GOOGLE_API_KEY="your_google_api_key"
$ export GOOGLE_CSE_ID="your_cse_id"
$ export OPENAI_API_KEY="your_openai_api_key"

Command Line Arguments

For example:
$ python main.py input_recipe_file.csv input_solubility_file.xlsx --no-download

  • input_recipe_file: The path to the input recipe file (required)
  • input_solubility_file: The path to the input solubility file (required)
  • --no-download: Skip the downloading step if Google Search resulted webpages are already downloaded (optional)

Usage

To use, run the following command:
$ python main.py recipe_clean.csv solubility_data.xlsx

  • Note: Solubility points can be customized by changing the number in water_solubility_points dictionary. (line 19 - 29 in main.py)

Credits

  • Yash Jahagirdar
  • Miloy Minar Ajmera
  • Aditya Dua
  • Shivam Patel
  • Wan-Tien (Candice) Chiang

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages