Прочетете на английски

Споделяне чрез


ChatClientExtensions.GetResponseAsync Method

Definition

Overloads

GetResponseAsync(IChatClient, ChatMessage, ChatOptions, CancellationToken)

Sends a chat message and returns the response messages.

GetResponseAsync(IChatClient, String, ChatOptions, CancellationToken)

Sends a user chat text message and returns the response messages.

GetResponseAsync(IChatClient, ChatMessage, ChatOptions, CancellationToken)

Sends a chat message and returns the response messages.

C#
public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatResponse> GetResponseAsync(this Microsoft.Extensions.AI.IChatClient client, Microsoft.Extensions.AI.ChatMessage chatMessage, Microsoft.Extensions.AI.ChatOptions? options = default, System.Threading.CancellationToken cancellationToken = default);

Parameters

client
IChatClient

The chat client.

chatMessage
ChatMessage

The chat message to send.

options
ChatOptions

The chat options to configure the request.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

The response messages generated by the client.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)

GetResponseAsync(IChatClient, String, ChatOptions, CancellationToken)

Sends a user chat text message and returns the response messages.

C#
public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatResponse> GetResponseAsync(this Microsoft.Extensions.AI.IChatClient client, string chatMessage, Microsoft.Extensions.AI.ChatOptions? options = default, System.Threading.CancellationToken cancellationToken = default);

Parameters

client
IChatClient

The chat client.

chatMessage
String

The text content for the chat message to send.

options
ChatOptions

The chat options to configure the request.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

The response messages generated by the client.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)