CosmosDBChatExtensions.WithCosmosDBChatHistoryProvider Method

Definition

Overloads

Name Description
WithCosmosDBChatHistoryProvider(ChatClientAgentOptions, CosmosClient, String, String, Func<AgentSession,CosmosChatHistoryProvider.State>)

Configures the agent to use Cosmos DB for message storage with an existing CosmosClient.

WithCosmosDBChatHistoryProvider(ChatClientAgentOptions, String, String, String, Func<AgentSession,CosmosChatHistoryProvider.State>)

Configures the agent to use Cosmos DB for message storage with connection string authentication.

WithCosmosDBChatHistoryProvider(ChatClientAgentOptions, CosmosClient, String, String, Func<AgentSession,CosmosChatHistoryProvider.State>)

Configures the agent to use Cosmos DB for message storage with an existing CosmosClient.

public static Microsoft.Agents.AI.ChatClientAgentOptions WithCosmosDBChatHistoryProvider(this Microsoft.Agents.AI.ChatClientAgentOptions options, Microsoft.Azure.Cosmos.CosmosClient cosmosClient, string databaseId, string containerId, Func<Microsoft.Agents.AI.AgentSession?,Microsoft.Agents.AI.CosmosChatHistoryProvider.State>? stateInitializer = default);
static member WithCosmosDBChatHistoryProvider : Microsoft.Agents.AI.ChatClientAgentOptions * Microsoft.Azure.Cosmos.CosmosClient * string * string * Func<Microsoft.Agents.AI.AgentSession, Microsoft.Agents.AI.CosmosChatHistoryProvider.State> -> Microsoft.Agents.AI.ChatClientAgentOptions
<Extension()>
Public Function WithCosmosDBChatHistoryProvider (options As ChatClientAgentOptions, cosmosClient As CosmosClient, databaseId As String, containerId As String, Optional stateInitializer As Func(Of AgentSession, CosmosChatHistoryProvider.State) = Nothing) As ChatClientAgentOptions

Parameters

options
ChatClientAgentOptions

The chat client agent options to configure.

cosmosClient
CosmosClient

The CosmosClient instance to use for Cosmos DB operations.

databaseId
String

The identifier of the Cosmos DB database.

containerId
String

The identifier of the Cosmos DB container.

stateInitializer
Func<AgentSession,CosmosChatHistoryProvider.State>

An optional delegate that initializes the provider state on the first invocation, providing the conversation routing info (conversationId, tenantId, userId). When not provided, a new conversation ID is generated automatically.

Returns

The configured ChatClientAgentOptions.

Exceptions

Thrown when any required parameter is null.

Thrown when any string parameter is null or whitespace.

Applies to

WithCosmosDBChatHistoryProvider(ChatClientAgentOptions, String, String, String, Func<AgentSession,CosmosChatHistoryProvider.State>)

Configures the agent to use Cosmos DB for message storage with connection string authentication.

public static Microsoft.Agents.AI.ChatClientAgentOptions WithCosmosDBChatHistoryProvider(this Microsoft.Agents.AI.ChatClientAgentOptions options, string connectionString, string databaseId, string containerId, Func<Microsoft.Agents.AI.AgentSession?,Microsoft.Agents.AI.CosmosChatHistoryProvider.State>? stateInitializer = default);
static member WithCosmosDBChatHistoryProvider : Microsoft.Agents.AI.ChatClientAgentOptions * string * string * string * Func<Microsoft.Agents.AI.AgentSession, Microsoft.Agents.AI.CosmosChatHistoryProvider.State> -> Microsoft.Agents.AI.ChatClientAgentOptions
<Extension()>
Public Function WithCosmosDBChatHistoryProvider (options As ChatClientAgentOptions, connectionString As String, databaseId As String, containerId As String, Optional stateInitializer As Func(Of AgentSession, CosmosChatHistoryProvider.State) = Nothing) As ChatClientAgentOptions

Parameters

options
ChatClientAgentOptions

The chat client agent options to configure.

connectionString
String

The Cosmos DB connection string.

databaseId
String

The identifier of the Cosmos DB database.

containerId
String

The identifier of the Cosmos DB container.

stateInitializer
Func<AgentSession,CosmosChatHistoryProvider.State>

An optional delegate that initializes the provider state on the first invocation, providing the conversation routing info (conversationId, tenantId, userId). When not provided, a new conversation ID is generated automatically.

Returns

The configured ChatClientAgentOptions.

Exceptions

Thrown when options is null.

Thrown when any string parameter is null or whitespace.

Applies to