jll38 / njitbytes

https://njitbytes.co
Other
2 stars 0 forks source link

Optimize OpenAI prompt for consistent JSON outputs for meal preps #26

Open jll38 opened 1 year ago

jll38 commented 1 year ago

We want a consistent JSON response from ChatGPT through its prompt just like this. In the meantime we have error handling in case the output is not parsable as JSON, but we don't want to waste API calls on errors.


      {
        "meal1": [
          {
            "ingredient": {
              "name": "Scrambled Eggs",
              "calories": "200",
              "carbs": "1g",
              "protein": "14g",
              "fat": "15g",
              "serving size": "1/2 cup"
            }
          },
          {
            "ingredient": {
              "name": "Pork Sausage Patty",
              "calories": "180",
              "carbs": "2g",
              "protein": "10g",
              "fat": "16g",
              "serving size": "1 each"
            }
          },
          {
            "ingredient": {
              "name": "Roasted Potatoes",
              "calories": "120",
              "carbs": "25g",
              "protein": "2g",
              "fat": "0g",
              "serving size": "4 ounce"
            }
          }
        ]
      },
      {
        "meal2": [
          {
            "ingredient": {
              "name": "Southwest Vegan Tofu Scramble",
              "calories": "90",
              "carbs": "3g",
              "protein": "8g",
              "fat": "5g",
              "serving size": "4 oz portion"
            }
          },
          {
            "ingredient": {
              "name": "Fresh Fruit",
              "calories": "60",
              "carbs": "15g",
              "protein": "1g",
              "fat": "0g",
              "serving size": "4 ounce"
            }
          }
        ]
      }
    ]
  }``