-
Notifications
You must be signed in to change notification settings - Fork 41
Support Structured Output As A Chat Completion Response Format #47
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Currently only two response formats are supported:
- Text
- Json Object
Which is good and reflects the latest up until fairly recently, a few months ago OpenAI released a more sophisticated evolution of JSON Object allows you to define the full JSON schema expected in the response - https://platform.openai.com/docs/guides/structured-outputs#structured-outputs-vs-json-mode
Solution
Add a new ChatCompletionResponseFormat variant for the json schema. There's a few ways to implement this that vary in complexity:
- Support Schema Builder like how OpenAI libraries do for Python and Javascript. I think relying on something like https://crates.io/crates/schemars would be the simplest approach for schema building but I can imagine that would
- Take in a schema via a JSON string and have the user be responsible for building that JSON schema and converting it into a JSON string themselves
There could be other alternative that I haven't noticed as well
Alternatives
Currently I use the Chat messages to communicate the schema via human language
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request