Making sure that response is ready to be JSON.parsed

My Message is
fill the following nutrient data ${{
name: ‘acorn squash’,
servingSize: '1/2 cup ',
weight: 102 grams,
calories: ‘’,
fiber: ‘’,
protein: ‘’,
fat: ‘’,
carbs: ‘’,
sugar: ‘’,
sodium: ‘’,
potassium: ‘’,
vitaminA: ‘’,
vitaminC: ‘’,
vitaminD: ‘’,
folate: ‘’,
}}

I want to make sure that replies will always be only the string of object and avoid any other texts like
Here is the …
or Certainly …

1 Like

You should tell that to the model, not to us :smile:
Also screaming, begging and insulting helps.


Hey bot make me a json.

Here example:

{}

Output as json without any explanations or other useless words outside json.

I am sick of such stuff! Behave! Please, please please.

ONLY JSON.

It really depends on the json though. Sometimes you need to explain more.
But the order of the prompt parts is important.

Especially the last sentence.

Could also repeat it there, but short as possible like:

Reply ONLY with json. No explanation or anything else.

Also an “else” is a good practice.

here example json:

{
“somekey”,…
}

if not possible answer with {}

You need to try a bit, but it definitely works even with gpt-3.5

And try to give a valid json as example.

instead of

${{

use

{

and always use " and don’t add newlines in values. Use \n.

And on top a retry logic after a json validate. I’d say 1 in 200 might be still wrong.

Or use function calls. But I concider them useless.