jll38 / jll38/njitbytes

Optimize OpenAI prompt for consistent JSON outputs for meal preps

Open
#26 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

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.
```"meals": [
{
"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"
}
}
]
}
]
}``

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.