Share via


PersistentAgentsClientExtensions.AsIChatClient Method

Definition

Creates an IChatClient for a PersistentAgentsClient client for interacting with a specific agent.

public static Microsoft.Extensions.AI.IChatClient AsIChatClient(this Azure.AI.Agents.Persistent.PersistentAgentsClient client, string agentId, string? defaultThreadId = default);
static member AsIChatClient : Azure.AI.Agents.Persistent.PersistentAgentsClient * string * string -> Microsoft.Extensions.AI.IChatClient
<Extension()>
Public Function AsIChatClient (client As PersistentAgentsClient, agentId As String, Optional defaultThreadId As String = Nothing) As IChatClient

Parameters

client
PersistentAgentsClient

The PersistentAgentsClient instance to be accessed as an IChatClient.

agentId
String

The unique identifier of the agent with which to interact.

defaultThreadId
String

An optional existing thread identifier for the chat session. This serves as a default, and may be overridden per call to GetResponseAsync(IEnumerable<ChatMessage>, ChatOptions, CancellationToken) or GetStreamingResponseAsync(IEnumerable<ChatMessage>, ChatOptions, CancellationToken) via the ConversationId property. If no thread ID is provided via either mechanism, a new thread will be created for the request.

Returns

An IChatClient instance configured to interact with the specified agent and thread.

Applies to