Class StructuredMessage
-
- All Implemented Interfaces:
public final class StructuredMessage<T extends Object>A wrapper for Message that provides type-safe access to the content when using the Structured Outputs feature to deserialize a JSON response to an instance of an arbitrary class. See the SDK documentation for more details on Structured Outputs.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classStructuredMessage.BuilderA builder for StructuredMessage.
-
Field Summary
Fields Modifier and Type Field Description private final Class<T>outputTypeprivate final MessagerawMessage
-
Method Summary
-
-
Method Detail
-
outputType
final Class<T> outputType()
-
rawMessage
final Message rawMessage()
-
content
final List<StructuredContentBlock<T>> content()
-
diagnostics
final Optional<Diagnostics> diagnostics()
-
stopDetails
final Optional<RefusalStopDetails> stopDetails()
-
stopReason
final Optional<StopReason> stopReason()
-
stopSequence
final Optional<String> stopSequence()
-
_id
final JsonField<String> _id()
Returns the raw JSON value of id.
Unlike id, this method doesn't throw if the JSON field has an unexpected type.
-
_container
final JsonField<Container> _container()
Returns the raw JSON value of container.
Unlike container, this method doesn't throw if the JSON field has an unexpected type.
-
_content
final JsonField<List<StructuredContentBlock<T>>> _content()
Returns the raw JSON value of content.
Unlike content, this method doesn't throw if the JSON field has an unexpected type.
-
_diagnostics
final JsonField<Diagnostics> _diagnostics()
Returns the raw JSON value of diagnostics.
Unlike diagnostics, this method doesn't throw if the JSON field has an unexpected type.
-
_model
final JsonField<Model> _model()
Returns the raw JSON value of model.
Unlike model, this method doesn't throw if the JSON field has an unexpected type.
-
_stopDetails
final JsonField<RefusalStopDetails> _stopDetails()
Returns the raw JSON value of stopDetails.
Unlike stopDetails, this method doesn't throw if the JSON field has an unexpected type.
-
_stopReason
final JsonField<StopReason> _stopReason()
Returns the raw JSON value of stopReason.
Unlike stopReason, this method doesn't throw if the JSON field has an unexpected type.
-
_stopSequence
final JsonField<String> _stopSequence()
Returns the raw JSON value of stopSequence.
Unlike stopSequence, this method doesn't throw if the JSON field has an unexpected type.
-
_usage
final JsonField<Usage> _usage()
Returns the raw JSON value of usage.
Unlike usage, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalProperties
final Map<String, JsonValue> _additionalProperties()
-
validate
final StructuredMessage<T> validate()
-
toBuilder
final StructuredMessage.Builder<T> toBuilder()
-
builder
final static <T extends Any> StructuredMessage.Builder<T> builder(Class<T> outputType)
Returns a mutable builder for constructing an instance of StructuredMessage.
The following fields are required:
.id() .container() .content() .diagnostics() .model() .stopDetails() .stopReason() .stopSequence() .usage()
-
-
-
-