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

Support structured responses from the ChatGPT API #735

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from

Conversation

joshuacoles
Copy link

This PR implements the response_format property from the OpenAI API Spec (link) to allow specifying. It is implemented using the Low Level Guidance project which allows token masking based on JSON schemas and a variant of BNF grammars.

There is support for JSON decoding, both with and without a supplied schema (although only supports a subset of JSON schemas). This is done by incorporating the masking process into the BufferedOutput object introduced in #734.

As with my other PRs this builds on them incrementally the others (#734, #720, #716) should be reviewed prior to this, I will keep this branch up to date with any changes from the prior PRs.

Still todo

  • Testing
  • Performance testing to minimise regressions in inference, especially when doing so without a grammar.

joshuacoles and others added 30 commits February 19, 2025 15:47
This removes direct references the internals of BufferedOutput to allow for better abstraction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant