Live data from Hacker News

Show HN: GPT-JSON – Structured and typehinted GPT responses in Python

github.com

71–76 of 76 posts

Re: Show HN: GPT-JSON – Structured and typehinted GPT responses in Python

#71

I asked ChatGPT (GPT-4) about the idea of integrating GPT-JSON with CUE language ( https://cuelang.org/ ) for potential improvements and the answers are quite impressive: "Yes, integrating the CUE language with GPT-JSON can potentially lead to improvements in its capability. CUE, short for Configuration, Unification, and Environment, is an open-source data constraint language designed to simplify the definition, gene…

Maybe not the best thread to ask, but - is there an ELI5 explanation of what exactly CUE is and what is it for? I've landed on that website several times in the last two years, and I could never make heads or tails of it. That the name is just a mix of random, unrelated verbs doesn't help.

Its a really well thought out way to combine schemas, templates, and data into one language. Its a superset of JSON and it provides a functional interface to validate inputs, outputs, and configurations.

It integrates very nicely with go and can convert between go structs into cue structs and vice versa.

Re: Show HN: GPT-JSON – Structured and typehinted GPT responses in Python

#72
post #61
post #7

Here's 40 lines of python code that I've found to be unreasonably effective at accomplishing something similar: https://github.com/jiggy-ai/pydantic-chatcompletion/blob/mas...

Thanks. Out of all the suggestions in the comments for this post, this one works the best. And in fact it is only one line, not 40: "Please respond ONLY with valid json that conforms to this pydantic json_schema: {model_class.schema_json()}. Do not include additional text other than the object json as we will load this object with json.loads() and pydantic."

yes thats actually it

Re: Show HN: GPT-JSON – Structured and typehinted GPT responses in Python

#73
post #7

Here's 40 lines of python code that I've found to be unreasonably effective at accomplishing something similar: https://github.com/jiggy-ai/pydantic-chatcompletion/blob/mas...

Very cool. Out of curiosity, for the retries why are the errors appended as system messages as opposed to appending to the user message? And in either case, would it help to prepend the error with something like “Be sure to avoid outputting something that would cause this error:”?

based on my experience with GPT-4 in coding tasks it responds extremely well to just appended raw error output text without additional explanation.

Re: Show HN: GPT-JSON – Structured and typehinted GPT responses in Python

#74
Nice project! I took some inspiration from this as well as https://github.com/jiggy-ai/pydantic-chatcompletion/blob/mas... to create the following:

https://github.com/knowsuchagency/struct-gpt

I tried to make the API as intuitive as possible and added the ability to provide examples to improve the reliability and quality of the LLM's output.

Re: Show HN: GPT-JSON – Structured and typehinted GPT responses in Python

#75

I've been interfacing with GPT programmatically for a little while now, leveraging it's "soft and fuzzy" interface to produce hard / machine-readable results. JSON was the format that felt best-suited for the job. I see a ton of code in this project, and I don't know what most of it does. As far as GPT troubles with JSON, I'll add a couple: sometimes it likes to throw comments in there as if it was JS. And sometimes…

I'm curious what you might think of https://github.com/knowsuchagency/struct-gpt
Post reply on HN