GPT-JSON: Structured and typehinted GPT responses in Python

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • jsonformer

    A Bulletproof Way to Generate Structured JSON from Language Models

  • Hey HN, I've been using GPT in some side projects mostly around data generation and benchmarking. During the course of prompt tuning I ended up with a 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.

    There's been some positive movement in this space, like with [jsonformer](https://github.com/1rgs/jsonformer) the other day. But nothing that was plug and play with GPT.

    This library consolidates the separate logic that I built across 5 different projects. It lets you hint the model for how it should return fields, variable inject prompts, handle common formatting errors, then cast to pydantic when you're done for typehinting and validation in your IDE. If you're able to play around with it, let me know what you think.

  • pydantic-chatcompletion

    Wraps openai.ChatCompletion to produce pydantic model output via schema prompt and error feedback.

  • 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.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • struct-gpt

    get structured output from LLM's

  • 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.

  • gpt-json

    Structured and typehinted GPT responses in Python

  • gpt-logic

    Translate the natural language generated by OpenAI's GPT models or any other large language models into JavaScript data types like booleans and objects.

  • I happen to have a very similar idea recently and created this GPT-logic package for node. It basically transforms GPT generated results into JS data types. Check it out if you are interested. https://github.com/wayneshn/gpt-logic

  • zod-chatgpt

  • I built zod-chatgpt https://github.com/olup/zod-chatgpt a couple of weeks ago to serve same purpose in typescript

  • cue

    The home of the CUE language! Validate and define text-based and dynamic configuration

  • I asked ChatGPT (GPT-4) about the idea of integrating GPT-JSON with CUE language (https://cuelang.org/) for improvement 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.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts