Remember that GPT is an autocompletion engine based on its training data.
So, you want to follow common practices. Better yet, you should start by giving it your desired JSON schema, and then ask it to modify/improve it to fit better into what it believes is correct. Dall-E is a great representation of this. If you prompt it correctly you can get beautiful, in-depth and consistent artwork. If your prompt is confusing, or lacks understanding, you get clip art mashed together in Microsoft Paint.
In the case of OP: their JSON structure makes no sense. Ideally your result should look something like this. Enough that it’s not too in-depth, but the fundamentals are there and can be understood.
{
"product": {
// Product Name
"name": string,
// Product cost (per square foot)
"cost": number,
// Stock availability
"inventory": number,
// Is it discontinued?
"isDiscontinued": boolean,
}
}
Then, you can refine it using GPT. I used Typescript as I believe it’s the best for consistency with GPT.
/**
* @typedef {Object} Product
*
* @property {string} name - Product Name
* @property {number} cost - Product cost (per square foot)
* @property {number} inventory - Stock availability
* @property {boolean} isDiscontinued - Is it discontinued?
*/
type Product = {
"name": string,
"cost": number,
"inventory": number,
"isDiscontinued": boolean,
}
5 samples produced
/**
* @type {Product}
*/
const product1 = {
name: 'Wooden Flooring',
cost: 10.5,
inventory: 150,
isDiscontinued: false,
}
/**
* @type {Product}
*/
const product2 = {
name: 'Marble Tiles',
cost: 20.0,
inventory: 100,
isDiscontinued: false,
}
/**
* @type {Product}
*/
const product3 = {
name: 'Laminate Flooring',
cost: 5.0,
inventory: 300,
isDiscontinued: true,
}
/**
* @type {Product}
*/
const product4 = {
name: 'Porcelain Tiles',
cost: 15.0,
inventory: 200,
isDiscontinued: false,
}
/**
* @type {Product}
*/
const product5 = {
name: 'Hardwood Flooring',
cost: 25.0,
inventory: 50,
isDiscontinued: true,
}
GPT wants to produce consistent JSON. But if your structure is confusing, or downright wrong, it will drift and produce errors.
Also note: it assumed I am selling flooring, possibly as a result of the price per square foot…