ChatClient class abstract

Represents a chat client.

Applications must consider risks such as prompt injection attacks, data sizes, and the number of messages sent to the underlying provider or returned from it. Unless a specific ChatClient implementation explicitly documents safeguards for these concerns, the application is expected to implement appropriate protections.

Implemented types
Implementers
Available extensions
Annotations
  • @Source(name: 'IChatClient.cs', namespace: 'Microsoft.Extensions.AI', repository: 'dotnet/extensions', path: 'src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/', commit: '09472076b1c0d53822d9ce085d9df408286bb867')

Constructors

ChatClient()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
inherited
getChatResponseFromMessage(ChatMessage message, {ChatOptions? options, CancellationToken? cancellationToken}) Future<ChatResponse>

Available on ChatClient, provided by the ChatClientExtensions extension

Sends a single message and returns the response.
getChatResponseFromText(String message, {ChatOptions? options, CancellationToken? cancellationToken}) Future<ChatResponse>

Available on ChatClient, provided by the ChatClientExtensions extension

Sends a single user text message and returns the response.
getResponse({required Iterable<ChatMessage> messages, ChatOptions? options, CancellationToken? cancellationToken}) Future<ChatResponse>
Sends a chat request and returns the complete response.
getService<T>({Object? key}) → T?
Gets a service of the specified type.
getStreamingChatResponseFromMessage(ChatMessage message, {ChatOptions? options, CancellationToken? cancellationToken}) Stream<ChatResponseUpdate>

Available on ChatClient, provided by the ChatClientExtensions extension

Sends a single message and returns a streaming response.
getStreamingChatResponseFromText(String message, {ChatOptions? options, CancellationToken? cancellationToken}) Stream<ChatResponseUpdate>

Available on ChatClient, provided by the ChatClientExtensions extension

Sends a single user text message and returns a streaming response.
getStreamingResponse({required Iterable<ChatMessage> messages, ChatOptions? options, CancellationToken? cancellationToken}) Stream<ChatResponseUpdate>
Sends a chat request and returns a stream of response updates.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited