Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand schema DSL to support optional fields #816

Open
simonw opened this issue Mar 4, 2025 · 2 comments
Open

Expand schema DSL to support optional fields #816

simonw opened this issue Mar 4, 2025 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Mar 4, 2025

I omitted optional field support in the original design - but that forces the model to hallucinate if a value is unavailable.

@simonw
Copy link
Owner Author

simonw commented Mar 4, 2025

One option could be to support a ? at the end of the field name:

name: their name
age? (Int)

Would that mean that the value in the key can be null, or would it mean the key can be omitted entirely?

I prefer nulls and consistently shaped objects, but in JSON schema I believe not having something in the required field means the key can be missing - a nullable property (is that widely supported?) indicates it can be null.

@simonw
Copy link
Owner Author

simonw commented Mar 4, 2025

I got ChatGPT Deep Research to research how different providers support JSON Schema: https://chatgpt.com/share/67c690de-d114-8006-9fad-d61122ac9b26

Here's the key information it dug up in a Gist: https://gist.github.com/simonw/bb0a8c24eb110e6ff9878a784356659a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant