StreamingChatCompletionUpdate Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a single streaming response chunk from an IChatClient.
public ref class StreamingChatCompletionUpdate
public class StreamingChatCompletionUpdate
type StreamingChatCompletionUpdate = class
Public Class StreamingChatCompletionUpdate
- Inheritance
-
StreamingChatCompletionUpdate
Remarks
Conceptually, this combines the roles of ChatCompletion and ChatMessage in streaming output. For ease of consumption, it also flattens the nested structure you see on streaming chunks in some AI service, so instead of a dictionary of choices, each update represents a single choice (and hence has its own role, choice ID, etc.).
StreamingChatCompletionUpdate is so named because it represents streaming updates to a single chat completion. As such, it is considered erroneous for multiple updates that are part of the same completion to contain competing values. For example, some updates that are part of the same completion may have a null
Role value, and others may have a non-null
value, but all of those with a non-null
value must have the same value (e.g. Assistant. It should never be the case, for example, that one StreamingChatCompletionUpdate in a completion has a role of Assistant while another has a role of "AI".
The relationship between ChatCompletion and StreamingChatCompletionUpdate is codified in the ToChatCompletionAsync(IAsyncEnumerable<StreamingChatCompletionUpdate>, Boolean, CancellationToken) and ToStreamingChatCompletionUpdates(), which enable bidirectional conversions between the two. Note, however, that the conversion may be slightly lossy, for example if multiple updates all have different RawRepresentation objects whereas there's only one slot for such an object available in RawRepresentation.
Constructors
StreamingChatCompletionUpdate() |
Properties
AdditionalProperties |
Gets or sets additional properties for the update. |
AuthorName |
Gets or sets the name of the author of the completion update. |
ChoiceIndex |
Gets or sets the zero-based index of the choice with which this update is associated in the streaming sequence. |
CompletionId |
Gets or sets the ID of the completion of which this update is a part. |
Contents |
Gets or sets the chat completion update content items. |
CreatedAt |
Gets or sets a timestamp for the completion update. |
FinishReason |
Gets or sets the finish reason for the operation. |
ModelId |
Gets or sets the model ID using in the creation of the chat completion of which this update is a part. |
RawRepresentation |
Gets or sets the raw representation of the completion update from an underlying implementation. |
Role |
Gets or sets the role of the author of the completion update. |
Text |
Gets or sets the text of the first TextContent instance in Contents. |
Methods
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. |