ChatResponse<T> Class

Definition

Represents the response to a chat request with structured output.

generic <typename T>
public ref class ChatResponse : Microsoft::Extensions::AI::ChatResponse
public class ChatResponse<T> : Microsoft.Extensions.AI.ChatResponse
type ChatResponse<'T> = class
    inherit ChatResponse
Public Class ChatResponse(Of T)
Inherits ChatResponse

Type Parameters

T

The type of value expected from the chat response.

Inheritance
ChatResponse<T>

Remarks

Language models are not guaranteed to honor the requested schema. If the model's output is not parseable as the expected type, then TryGetResult(T) will return false. You can access the underlying JSON response on the Text property.

Constructors

ChatResponse<T>(ChatResponse, JsonSerializerOptions)

Initializes a new instance of the ChatResponse<T> class.

Properties

AdditionalProperties

Gets or sets any additional properties associated with the chat response.

(Inherited from ChatResponse)
ConversationId

Gets or sets an identifier for the state of the conversation.

(Inherited from ChatResponse)
CreatedAt

Gets or sets a timestamp for the chat response.

(Inherited from ChatResponse)
FinishReason

Gets or sets the reason for the chat response.

(Inherited from ChatResponse)
Messages

Gets or sets the chat response messages.

(Inherited from ChatResponse)
ModelId

Gets or sets the model ID used in the creation of the chat response.

(Inherited from ChatResponse)
RawRepresentation

Gets or sets the raw representation of the chat response from an underlying implementation.

(Inherited from ChatResponse)
ResponseId

Gets or sets the ID of the chat response.

(Inherited from ChatResponse)
Result

Gets the result value of the chat response as an instance of T.

Text

Gets the text of the response.

(Inherited from ChatResponse)
Usage

Gets or sets usage details for the chat response.

(Inherited from ChatResponse)

Methods

ToChatResponseUpdates()

Creates an array of ChatResponseUpdate instances that represent this ChatResponse.

(Inherited from ChatResponse)
ToString()

Returns a string that represents the current object.

(Inherited from ChatResponse)
TryGetResult(T)

Attempts to deserialize the result to produce an instance of T.

Extension Methods

RenderText(ChatResponse)

Renders the supplied response to a string. The returned string can used as part of constructing an evaluation prompt to evaluate a conversation that includes the supplied response.

Applies to