Dela via


IChatClient Interface

Definition

Represents a chat completion client.

public interface class IChatClient : IDisposable
public interface IChatClient : IDisposable
type IChatClient = interface
    interface IDisposable
Public Interface IChatClient
Implements IDisposable
Derived
Implements

Remarks

Unless otherwise specified, all members of IChatClient are thread-safe for concurrent use. It is expected that all implementations of IChatClient support being used by multiple requests concurrently.

However, implementations of IChatClient may mutate the arguments supplied to CompleteAsync(IList<ChatMessage>, ChatOptions, CancellationToken) and CompleteStreamingAsync(IList<ChatMessage>, ChatOptions, CancellationToken), such as by adding additional messages to the messages list or configuring the options instance. Thus, consumers of the interface either should avoid using shared instances of these arguments for concurrent invocations or should otherwise ensure by construction that no IChatClient instances are used which might employ such mutation. For example, the WithChatOptions method be provided with a callback that could mutate the supplied options argument, and that should be avoided if using a singleton options instance.

Properties

Metadata

Gets metadata that describes the IChatClient.

Methods

CompleteAsync(IList<ChatMessage>, ChatOptions, CancellationToken)

Sends chat messages to the model and returns the response messages.

CompleteStreamingAsync(IList<ChatMessage>, ChatOptions, CancellationToken)

Sends chat messages to the model and streams the response messages.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from IDisposable)
GetService<TService>(Object)

Asks the IChatClient for an object of type TService.

Extension Methods

CompleteAsync(IChatClient, String, ChatOptions, CancellationToken)

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

CompleteStreamingAsync(IChatClient, String, ChatOptions, CancellationToken)

Sends a user chat text message to the model and streams the response messages.

CompleteAsync<T>(IChatClient, IList<ChatMessage>, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends chat messages to the model, requesting a response matching the type T.

CompleteAsync<T>(IChatClient, IList<ChatMessage>, JsonSerializerOptions, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends chat messages to the model, requesting a response matching the type T.

CompleteAsync<T>(IChatClient, String, ChatOptions, Nullable<Boolean>, CancellationToken)

Sends a user chat text message to the model, requesting a response matching the type T.

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.

Applies to