superman attacking a computer containing zodresponseformat

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

4 Comments

  1. Leonard Ikeh says:

    Excellent post, so far this is the best way I’ve seen when it comes to handling JSON responses when prompting OpenAI.

  2. I would like to see the json schema you used but failed. They do say that you can use json schema in the docs but recommend either zod or pydantic.

    Would also appreciate seeing how you tried to use anyOf.

    Also I don’t quite understand what .describe() is for. Looking at the zod docs I found “Use .describe() to add a description property to the resulting schema.” Would this be kind of like comments inside the schema to help the developer understand the schema or am I misunderstanding?

    About “zodResponseFormat(Schema, “schemaName”)” this schemaName doesn’t seem to be used anywhere else, it’s only needed for calling zodResponseFormat() is that correct?

    I decided to open up the node module where where zod is and ask chatgpt about some of the code there. Here is a link https://chatgpt.com/share/672cbeae-375c-8013-9442-b4ed6e5570be

    It is in fact converting the zod schema into a json schema so we should be able to write directly in json schema format.I think the key to why they recommend zod is that it has validator. With json schema youll have to figure that part out yourself and they have a looong list of validators.

    Now how accurate are the chatgpt answers I can’t say. Apparently name is there for tracking errors. And zodResponseFormat has an additional argument which is “props” which is not mentioned in the openai docs for some reason. According to chatgpt it can be used for adding meta data/ descriptions or whatever.

    As far as why they released it in it’s current limited state I think for people to try it out and I believe there are some developers such as myself who could really benefit from it as it is currently. Though I’m still not a professional, it’s just for personal projects.

    1. Hey there, I didn’t keep a record of the broken schema I used — I just realised an easier path forward was to use zod. Because openai updates their npm package constantly, I thought the schema creation code might also be regularly updated (and it has definitely updated in the time I’ve been using it), so I do think it’s the best path forward for now.