-
Notifications
You must be signed in to change notification settings - Fork 105
Structured outputs #463
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
base: next
Are you sure you want to change the base?
Structured outputs #463
Conversation
openai-java-core/src/main/kotlin/com/openai/models/chat/completions/StructuredChatCompletion.kt
Outdated
Show resolved
Hide resolved
openai-java-core/src/main/kotlin/com/openai/models/chat/completions/StructuredChatCompletion.kt
Outdated
Show resolved
Hide resolved
...e/src/main/kotlin/com/openai/models/chat/completions/StructuredChatCompletionCreateParams.kt
Outdated
Show resolved
Hide resolved
...a-core/src/main/kotlin/com/openai/models/chat/completions/StructuredChatCompletionMessage.kt
Outdated
Show resolved
Hide resolved
openai-java-core/src/main/kotlin/com/openai/core/JsonSchemaValidator.kt
Outdated
Show resolved
Hide resolved
8c0d60a
to
67381ff
Compare
} | ||
``` | ||
|
||
Pass the top-level class—`BookList` in this example—to `responseFormat(Class<T>)` when building the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the top-level class—`BookList` in this example—to `responseFormat(Class<T>)` when building the | |
Pass the top-level class—`BookList` in this example to `responseFormat(Class<T>)` when building the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parenthetical phrase is "Booklist
in this example". It is delimited by em dashes to give it more emphasis than it would have it if were delimited by parentheses or commas, as it helps to clarify what "top-level class" means in this context. Taking out one of the dashes would be like taking out a closing parenthesis while keeping the opening one.
List<String> books = new ArrayList<>(); | ||
|
||
StructuredChatCompletionCreateParams<BookList> params = ChatCompletionCreateParams.builder() | ||
.responseFormat(books.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.responseFormat(books.class) | |
.responseFormat(books.getClass()) |
(the previous code wouldn't have compiled)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Luckily, that was in code that was introduced with, "the following will not work". I'm a man of my word!
```java | ||
List<String> books = new ArrayList<>(); | ||
|
||
StructuredChatCompletionCreateParams<BookList> params = ChatCompletionCreateParams.builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StructuredChatCompletionCreateParams<BookList> params = ChatCompletionCreateParams.builder() | |
StructuredChatCompletionCreateParams<List<String>> params = ChatCompletionCreateParams.builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to write it as List<Book>
, the same as the field from the BookList
class. Clearly, I was not operating on all cylinders at that moment.
Includes optional local JSON schema validation and draft SDK documentation.