I think there are a few tricks I use to get correct code:
1) GPT4 is a must, the code quality is so much better than GPT3
2) You can use a longer explanation than you think. Be detailed in exactly what you want. Clearly describe function inputs and outputs.
3) Provide GPT3 with the APIs to use, and break these down. If you want it to call an API and do some logic, you can prompt it twice - once to build a function to get data from the API and once to build a function that requests from the function in the first request. Do both of these as separate chat GPT sessions.
4) Give GPT a chance to fix errors - pipe the exact errors back in after you have run them so GPT can amend its code.
5) if you want the code to operate/be written in a particular way then tell GPT and even provide pseudo code if worthwhile. If you want error handling, request it. If you want the SQL statements to be run in a transaction, request it. It probably won’t do these things by default.
1) GPT4 is a must, the code quality is so much better than GPT3
2) You can use a longer explanation than you think. Be detailed in exactly what you want. Clearly describe function inputs and outputs.
3) Provide GPT3 with the APIs to use, and break these down. If you want it to call an API and do some logic, you can prompt it twice - once to build a function to get data from the API and once to build a function that requests from the function in the first request. Do both of these as separate chat GPT sessions.
4) Give GPT a chance to fix errors - pipe the exact errors back in after you have run them so GPT can amend its code.
5) if you want the code to operate/be written in a particular way then tell GPT and even provide pseudo code if worthwhile. If you want error handling, request it. If you want the SQL statements to be run in a transaction, request it. It probably won’t do these things by default.
6) don’t use even slightly obscure languages.