PersistentAgentsClientExtensions.AsIChatClient 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.
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, bool throwOnContentErrors = true);
static member AsIChatClient : Azure.AI.Agents.Persistent.PersistentAgentsClient * string * string * bool -> Microsoft.Extensions.AI.IChatClient
<Extension()>
Public Function AsIChatClient (client As PersistentAgentsClient, agentId As String, Optional defaultThreadId As String = Nothing, Optional throwOnContentErrors As Boolean = true) 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.
- throwOnContentErrors
- Boolean
Throws an exception if content errors are returned from the service. Default is true. This is useful to detect errors when tools are misconfigured that otherwise would be unnoticed because those come as a streaming data update.
Returns
An IChatClient instance configured to interact with the specified agent and thread.