Parsing JSON Into zod schema using OPENAI GPT

I want to parse a JSON example https://store.steampowered.com/api/appdetails?appids=1702010 Into large advanced zod schema. Do you guys have any experience doing this with gpt openai package?? Seems like pretty normal use case but I can't find any good examples
33 Replies
iDarkLightning
iDarkLightning9mo ago
idk about AI but have you tried: https://transform.tools/json-to-zod
JSON to Zod Schema
An online playground to convert JSON to Zod Schema
Jaaneek
Jaaneek9mo ago
I’m sorry but this is not even close. I want any data => json formatted according to zod schema 😄
iDarkLightning
iDarkLightning9mo ago
what do you mean
Jaaneek
Jaaneek9mo ago
I want to parse any input into a JSON that has schema defined in zod.
iDarkLightning
iDarkLightning9mo ago
wdym "any input into a JSON" be specific here, give an example input
Jaaneek
Jaaneek9mo ago
I guess you don’t understand how does gpt work, I want to put literally any string on earth and I want the gpt to output JSON from it. It’s pretty normal use case. For example v0.dev does it but without zod. Here is example input https://store.steampowered.com/api/appdetails?appids=1702010 I’m already doing it as well but the gpt is hallucinating a lot for me and Im looking for some good practices/tips/snippets
iDarkLightning
iDarkLightning9mo ago
your example input is JSON bud
Jaaneek
Jaaneek9mo ago
Sorry @iDarkLightning I think you are not helping here, you don’t understand my question. If you are curious about this topic feel free to DM me but let’s not spam this topic so others will be more willingly to give answers
Strike
Strike9mo ago
Why are you using the raw API? There's node packages that make this easier
Jaaneek
Jaaneek9mo ago
I’m using OpenAI npm package but I have trouble incorporating the zod schema into it, even with the examples @Strike
Jaaneek
Jaaneek9mo ago
I’m using this one https://www.npmjs.com/package/openai @Strike
npm
openai
The official TypeScript library for the OpenAI API. Latest version: 4.24.7, last published: 4 days ago. Start using openai in your project by running npm i openai. There are 1427 other projects in the npm registry using openai.
Strike
Strike9mo ago
@Jaaneek no like I mean accessing steam API Or what exactly are you trying to do? I'm a bit confused
iDarkLightning
iDarkLightning9mo ago
give us an example of the JSON that the gpt would output if I gave it the string "I like web development"
Jaaneek
Jaaneek9mo ago
1. I’m fetching the data from steam API 2. Im using this json from steam API as input to GPT 3. I Ask gpt to use data from steam API JSON and put it into JSON that is defined by my zod schema …. I want it to be generic so I can also fetch the data from other places and always have it in my zod defined JSON format
Strike
Strike9mo ago
I see but you don't only want it to work for the steam API?
Want results from more Discord servers?
Add your server