Show HN: A tool to Convert JSON schemas into TypeScript Deno classes (github.com)
To preface this is just something I've been making as a learning exercise, so all feedback is appreciated.
This is a tool that converts JSON schemas into TypeScript utility classes for use in Deno.
Automatic Type Generation: Typescript interfaces for the compressed and uncompressed versions of your data.
Compression & Decompression: Compress and decompress your data.
Validation: Built-in data validation using Ajv ensures your data adheres to the schema.
Reusability: Once generated, the utility classes can be used in other Deno projects.
It currently only supports a subset of JSON schema features. I'll eventually hope to expand it to support more features.
Reasons behind the project: I have been working with OpenAI LLMs recently and I like to get my data output in structured JSON. I realised it's rather good at taking a schema where properties are compressed within an instruction, and then in return it return data based on the compressed schema. These utility classes provide help with the validation, decompression etc.
16 comments
[ 1.9 ms ] story [ 44.5 ms ] threadOpenAI Function Calling does JSON to Typescript conversion under the hood for functions so I'm not surprised it works well.
No need to be formal or use a standard format, just need a pattern the LLM can fill or follow
My thought was it may have been trained on so much JSON and JSON schema data, that simply providing a JSON schema and telling it the data it outputs must validate against the schema will produce good results.
gpt-3.5-turbo and gpt-4 have worked superb at this so far and I'm excited to test with the new gpt-3.5-turbo-instruct model!
One of the benefits of using a reduced syntax is reduced tokens, so the LLM can focus on the interesting parts while ignoring uninteresting " and ,
Let the model think more (and about the important parts)
[1] https://bun.sh/docs/bundler/macros
Yes it was rather tricky! It's been a great learning exercise for sure.
https://github.com/hyperjump-io/json-schema