Class AssistantResponseFormatOption
-
- All Implemented Interfaces:
public final class AssistantResponseFormatOption
Specifies the format that the model must output. Compatible with GPT-4o, [GPT-4
Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since
gpt-3.5-turbo-1106
.
Setting to
{ "type": "json_schema", "json_schema": {...} }
enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.Setting to
{ "type": "json_object" }
enables JSON mode, which ensures the message the model generates is valid JSON.Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if
finish_reason="length"
, which indicates the generation exceededmax_tokens
or the conversation exceeded the max context length.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
AssistantResponseFormatOption.Visitor
An interface that defines how to map each variant of AssistantResponseFormatOption to a value of type T.
-
Method Summary
-
-
Method Detail
-
responseFormatText
final Optional<ResponseFormatText> responseFormatText()
-
responseFormatJsonObject
final Optional<ResponseFormatJsonObject> responseFormatJsonObject()
-
responseFormatJsonSchema
final Optional<ResponseFormatJsonSchema> responseFormatJsonSchema()
-
isResponseFormatText
final Boolean isResponseFormatText()
-
isResponseFormatJsonObject
final Boolean isResponseFormatJsonObject()
-
isResponseFormatJsonSchema
final Boolean isResponseFormatJsonSchema()
-
asResponseFormatText
final ResponseFormatText asResponseFormatText()
-
asResponseFormatJsonObject
final ResponseFormatJsonObject asResponseFormatJsonObject()
-
asResponseFormatJsonSchema
final ResponseFormatJsonSchema asResponseFormatJsonSchema()
-
accept
final <T extends Any> T accept(AssistantResponseFormatOption.Visitor<T> visitor)
-
validate
final AssistantResponseFormatOption validate()
-
ofAuto
final static AssistantResponseFormatOption ofAuto()
auto
is the default value
-
ofResponseFormatText
final static AssistantResponseFormatOption ofResponseFormatText(ResponseFormatText responseFormatText)
-
ofResponseFormatJsonObject
final static AssistantResponseFormatOption ofResponseFormatJsonObject(ResponseFormatJsonObject responseFormatJsonObject)
-
ofResponseFormatJsonSchema
final static AssistantResponseFormatOption ofResponseFormatJsonSchema(ResponseFormatJsonSchema responseFormatJsonSchema)
-
-
-
-