News for hackers. Stuff that matters.
Re:GPT-JSON: Structured and typehinted GPT responses in Python by teleforce on Friday May 05, 2023 @03:07AM (#35826192)
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, generation, and validation of data in structured formats, like JSON, YAML, and others.

Integrating CUE with GPT-JSON can bring several benefits:

1) Validation: By using CUE, you can define schemas for the input and output JSON, which helps in validating the data structure and ensuring it adheres to the expected format. This can help reduce errors and improve the quality of the interaction with the GPT model.

2) Simplification: CUE can help simplify the process of defining and generating JSON inputs and outputs for GPT-JSON. By providing a more concise and expressive syntax, CUE can make it easier to craft structured inputs and outputs, which can be especially helpful when working with complex data structures.

3) Interoperability: Integrating CUE can improve the interoperability between GPT-JSON and other systems or applications. With CUE's ability to work with multiple data formats (such as JSON, YAML, or HCL), it becomes easier to integrate GPT-JSON with various tools and platforms.

To integrate CUE with GPT-JSON, you would need to follow these general steps:

1) Define CUE schemas for the input and output JSON structures used by GPT-JSON.

2) Use the CUE language to validate and generate input JSON for GPT-JSON.

3) Process the output JSON generated by GPT-JSON using CUE to ensure it adheres to the defined schema and transform it as needed.

Integrating CUE with GPT-JSON can improve the overall robustness and ease of use of the library, making it more accessible and useful for a wider range of applications."

Re:GPT-JSON: Structured and typehinted GPT responses in Python by TeMPOraL on Friday May 05, 2023 @05:23AM (#35826981)
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.
Re:GPT-JSON: Structured and typehinted GPT responses in Python by verdverm on Friday May 05, 2023 @10:50AM (#35829963)
Re:GPT-JSON: Structured and typehinted GPT responses in Python by mhsred5 on Friday May 05, 2023 @03:42PM (#35834214)
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:GPT-JSON: Structured and typehinted GPT responses in Python by verdverm on Friday May 05, 2023 @11:11AM (#35830258)
I think you could implement the entire thing in CUE, minus moving from/to python. We're already going what the last 3 points instruct the user to do for integration. We are using Go rather than Python, so the CUE to language types has better integrations. Of course, there is the prompt engineering side, but that is just text with instructions for the LLM that need to be well crafted.

One thing we have seen is that you need to adjust your prompts when OpenAI updates their model. Given they only support their dated models for so long, it seems increasingly difficult to make the case to build on top of LLMs you cannot control the life cycle for.

Re:GPT-JSON: Structured and typehinted GPT responses in Python by icyfox on Friday May 05, 2023 @12:36PM (#35831721)
Pretty good pitch from ChatGPT if you ask me! I haven't used cue outside of test projects before, so a few questions:

1. Is cue's validation a material improvement from something like pydantic or zod, which defines schema as code versus in .cue files? I see their docs argue that this can allow for client-side validation and lighter weight schema files which doesn't seem to totally address the library side of things.

2. Have you used the scripting layer before and do you find it useful in practice? I'm struggling a bit to see how I or GPT would use this in my day-to-day.

Re:GPT-JSON: Structured and typehinted GPT responses in Python by mhsred5 on Friday May 05, 2023 @03:37PM (#35834156)
CUE's validation is very strong, as long as you're ok with some level of functional programming and immutability.

Despite what GPT said above, its Configure, Unify, Execute. The Execute aspect is powerful but you have to be ok with functional programming and immutability.

Pairs up really nicely with Go.