StructuredChatResponse<T> class

Represents the response to a chat request with structured output.

Language models are not guaranteed to honor the requested schema. If the model's output is not parseable, tryGetResult returns null; the raw JSON remains available via ChatResponse.text.

Because the port performs no runtime reflection, deserialization is driven by the StructuredResultFromJson callback supplied at creation.

Inheritance
Annotations
  • @Source(name: 'ChatResponse{T}.cs', namespace: 'Microsoft.Extensions.AI', repository: 'dotnet/extensions', path: 'src/Libraries/Microsoft.Extensions.AI/ChatCompletion/')

Constructors

StructuredChatResponse(ChatResponse response, {required StructuredResultFromJson<T> fromJson, bool wrappedInObject = false})
Creates a structured view over response.

Properties

additionalProperties AdditionalPropertiesDictionary?
Additional properties.
getter/setter pairinherited
continuationToken ResponseContinuationToken?
A token to resume an interrupted response.
getter/setter pairinherited
conversationId String?
A conversation state identifier.
getter/setter pairinherited
createdAt DateTime?
When the response was created.
getter/setter pairinherited
finishReason ChatFinishReason?
The reason the response finished being generated.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
messages List<ChatMessage>
The response messages.
finalinherited
modelId String?
The model that generated this response.
getter/setter pairinherited
rawRepresentation Object?
The underlying implementation-specific object.
getter/setter pairinherited
responseId String?
A unique identifier for the response.
getter/setter pairinherited
result → T
The result value of the chat response as an instance of T.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
text String
Gets concatenated text from the last message's TextContent items.
no setterinherited
usage UsageDetails?
Usage details for the request/response.
getter/setter pairinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toChatResponseUpdates() List<ChatResponseUpdate>
Converts this response into a list of ChatResponseUpdates.
inherited
toString() String
A string representation of this object.
inherited
tryGetResult() → T?
Attempts to deserialize the result, returning null on any failure.

Operators

operator ==(Object other) bool
The equality operator.
inherited