Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I could not get GPT-4 to reliably not give some sort of text response, even if was just a simple "Sure" followed by the JSON.


Pass in an agent message with "Sure here is the answer in json format:" after the user message. Gpt will think it has already done the preamble and the rest of the message will start right with the json.


Did you try using the API and providing a very clear system message followed by several examples that were pure JSON?


Yep. I even gave it a JSON schema file to use. It just wouldn't stop added extra verbage.


I just use a regex to select everything between the first and last curly bracket, reliable fixes the “sure, here’s your object” problem.


Say it's a json API and may only reply with valid json without explanation.


Lol yes of course I tried that.


I've had good luck with both:

https://github.com/drorm/gish/blob/main/tasks/coding.txt

and

https://github.com/drorm/gish/blob/main/tasks/webapp.txt

With the second one, I reliably generated half a dozen apps with one command.

Not to say that it won't fail sometimes.


Combine both ? :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: