ChatClientStructuredOutputExtensions.CompleteAsync Method
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.
Overloads
CompleteAsync<T>(IChatClient, IList<ChatMessage>, ChatOptions, Nullable<Boolean>, CancellationToken) |
Sends chat messages to the model, requesting a response matching the type |
CompleteAsync<T>(IChatClient, String, ChatOptions, Nullable<Boolean>, CancellationToken) |
Sends a user chat text message to the model, requesting a response matching the type |
CompleteAsync<T>(IChatClient, IList<ChatMessage>, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken) |
Sends chat messages to the model, requesting a response matching the type |
CompleteAsync<T>(IChatClient, String, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken) |
Sends a user chat text message to the model, requesting a response matching the type |
CompleteAsync<T>(IChatClient, IList<ChatMessage>, ChatOptions, Nullable<Boolean>, CancellationToken)
Sends chat messages to the model, requesting a response matching the type T
.
public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion<T>> CompleteAsync<T> (this Microsoft.Extensions.AI.IChatClient chatClient, System.Collections.Generic.IList<Microsoft.Extensions.AI.ChatMessage> chatMessages, Microsoft.Extensions.AI.ChatOptions? options = default, bool? useNativeJsonSchema = default, System.Threading.CancellationToken cancellationToken = default);
static member CompleteAsync : Microsoft.Extensions.AI.IChatClient * System.Collections.Generic.IList<Microsoft.Extensions.AI.ChatMessage> * Microsoft.Extensions.AI.ChatOptions * Nullable<bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion<'T>>
<Extension()>
Public Function CompleteAsync(Of T) (chatClient As IChatClient, chatMessages As IList(Of ChatMessage), Optional options As ChatOptions = Nothing, Optional useNativeJsonSchema As Nullable(Of Boolean) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ChatCompletion(Of T))
Type Parameters
- T
The type of structured output to request.
Parameters
- chatClient
- IChatClient
The IChatClient.
- chatMessages
- IList<ChatMessage>
The chat content to send.
- options
- ChatOptions
The chat options to configure the request.
Optionally specifies whether to set a JSON schema on the ChatResponseFormat. This improves reliability if the underlying model supports native structured output with a schema, but may cause an error if the model does not support it. If not specified, the underlying provider's default will be used.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
The response messages generated by the client.
Remarks
The returned messages will not have been added to chatMessages
. However, any intermediate messages generated implicitly by the client, including any messages for roundtrips to the model as part of the implementation of this request, will be included.
Applies to
CompleteAsync<T>(IChatClient, String, ChatOptions, Nullable<Boolean>, CancellationToken)
Sends a user chat text message to the model, requesting a response matching the type T
.
public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion<T>> CompleteAsync<T> (this Microsoft.Extensions.AI.IChatClient chatClient, string chatMessage, Microsoft.Extensions.AI.ChatOptions? options = default, bool? useNativeJsonSchema = default, System.Threading.CancellationToken cancellationToken = default);
static member CompleteAsync : Microsoft.Extensions.AI.IChatClient * string * Microsoft.Extensions.AI.ChatOptions * Nullable<bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion<'T>>
<Extension()>
Public Function CompleteAsync(Of T) (chatClient As IChatClient, chatMessage As String, Optional options As ChatOptions = Nothing, Optional useNativeJsonSchema As Nullable(Of Boolean) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ChatCompletion(Of T))
Type Parameters
- T
The type of structured output to request.
Parameters
- chatClient
- IChatClient
The IChatClient.
- chatMessage
- String
The text content for the chat message to send.
- options
- ChatOptions
The chat options to configure the request.
Optionally specifies whether to set a JSON schema on the ChatResponseFormat. This improves reliability if the underlying model supports native structured output with a schema, but may cause an error if the model does not support it. If not specified, the underlying provider's default will be used.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
The response messages generated by the client.
Applies to
CompleteAsync<T>(IChatClient, IList<ChatMessage>, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken)
Sends chat messages to the model, requesting a response matching the type T
.
public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion<T>> CompleteAsync<T> (this Microsoft.Extensions.AI.IChatClient chatClient, System.Collections.Generic.IList<Microsoft.Extensions.AI.ChatMessage> chatMessages, System.Text.Json.JsonSerializerOptions serializerOptions, Microsoft.Extensions.AI.ChatOptions? options = default, bool? useNativeJsonSchema = default, System.Threading.CancellationToken cancellationToken = default);
static member CompleteAsync : Microsoft.Extensions.AI.IChatClient * System.Collections.Generic.IList<Microsoft.Extensions.AI.ChatMessage> * System.Text.Json.JsonSerializerOptions * Microsoft.Extensions.AI.ChatOptions * Nullable<bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion<'T>>
<Extension()>
Public Function CompleteAsync(Of T) (chatClient As IChatClient, chatMessages As IList(Of ChatMessage), serializerOptions As JsonSerializerOptions, Optional options As ChatOptions = Nothing, Optional useNativeJsonSchema As Nullable(Of Boolean) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ChatCompletion(Of T))
Type Parameters
- T
The type of structured output to request.
Parameters
- chatClient
- IChatClient
The IChatClient.
- chatMessages
- IList<ChatMessage>
The chat content to send.
- serializerOptions
- JsonSerializerOptions
The JSON serialization options to use.
- options
- ChatOptions
The chat options to configure the request.
Optionally specifies whether to set a JSON schema on the ChatResponseFormat. This improves reliability if the underlying model supports native structured output with a schema, but may cause an error if the model does not support it. If not specified, the underlying provider's default will be used.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
The response messages generated by the client.
Remarks
The returned messages will not have been added to chatMessages
. However, any intermediate messages generated implicitly by the client, including any messages for roundtrips to the model as part of the implementation of this request, will be included.
Applies to
CompleteAsync<T>(IChatClient, String, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken)
Sends a user chat text message to the model, requesting a response matching the type T
.
public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion<T>> CompleteAsync<T> (this Microsoft.Extensions.AI.IChatClient chatClient, string chatMessage, System.Text.Json.JsonSerializerOptions serializerOptions, Microsoft.Extensions.AI.ChatOptions? options = default, bool? useNativeJsonSchema = default, System.Threading.CancellationToken cancellationToken = default);
static member CompleteAsync : Microsoft.Extensions.AI.IChatClient * string * System.Text.Json.JsonSerializerOptions * Microsoft.Extensions.AI.ChatOptions * Nullable<bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion<'T>>
<Extension()>
Public Function CompleteAsync(Of T) (chatClient As IChatClient, chatMessage As String, serializerOptions As JsonSerializerOptions, Optional options As ChatOptions = Nothing, Optional useNativeJsonSchema As Nullable(Of Boolean) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ChatCompletion(Of T))
Type Parameters
- T
The type of structured output to request.
Parameters
- chatClient
- IChatClient
The IChatClient.
- chatMessage
- String
The text content for the chat message to send.
- serializerOptions
- JsonSerializerOptions
The JSON serialization options to use.
- options
- ChatOptions
The chat options to configure the request.
Optionally specifies whether to set a JSON schema on the ChatResponseFormat. This improves reliability if the underlying model supports native structured output with a schema, but may cause an error if the model does not support it. If not specified, the underlying provider's default will be used.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
The response messages generated by the client.