{"by":"icyfox","descendants":72,"id":35821748,"kids":[35825064,35825300,35830239,35828442,35826130,35826192,35826928,35825482,35831056,35832127,35827039,35827996,35827068,35825530,35855388,35825909,35825077,35826162,35826756,35826241,35825685,35825690,35826524,35827154,35927719,35822017],"score":174,"text":"Hey HN, I&#x27;ve been using GPT a lot lately in some side projects around data generation and benchmarking. During the course of prompt tuning I ended up with a pretty complicated request: the value that I was looking for, an explanation, a criticism, etc. JSON was the most natural output format for this but results would often be broken, have wrong types, or contain missing fields.<p>There&#x27;s been some positive movement in this space, like with jsonformer (<a href=\"https:&#x2F;&#x2F;github.com&#x2F;1rgs&#x2F;jsonformer\">https:&#x2F;&#x2F;github.com&#x2F;1rgs&#x2F;jsonformer</a>) the other day. But nothing that was plug and play with GPT.<p>This library consolidates the separate logic that I built across 5 different projects. It lets you prompt the model for how it should return fields, inject variable prompts, handle common formatting errors, then cast to pydantic when you&#x27;re done for typehinting and validation in your IDE. If you&#x27;re able to play around with it, let me know what you think.","time":1683232797,"title":"Show HN: GPT-JSON – Structured and typehinted GPT responses in Python","type":"story","url":"https://github.com/piercefreeman/gpt-json"}