In the ChatHistoryRecord class, we are currently using both Newtonsoft.Json and System.Text.Json for decorating properties:
|
[JsonProperty(@"id")] |
|
[JsonPropertyName(@"id")] |
|
public virtual string Id { get; init; } |
This class is ultimately used to retrieve chat history through the ChatHistoryProvider, which utilizes an IAsyncRepository configured with a CosmosDB implementation.
The goal is to standardize the JSON serialization to use only System.Text.Json. To achieve this, changes would be needed in the Cosmos client initialization to support this configuration.
|
client = this.options.UseDefaultAzureCredentialAuthentication |
|
? new CosmosClient(this.options.Endpoint, new DefaultAzureCredential()) |
|
: new CosmosClient(this.options.Endpoint, this.options.AuthKey, BuildCosmosClientOptions(this.options)); |
Current approach: To enable System.Text.Json in the Cosmos client today, it can be configured as follows:
var cosmosClient = new CosmosClient(this.options.Endpoint, new DefaultAzureCredential(), new CosmosClientOptions()
{
UseSystemTextJsonSerializerWithOptions = JsonSerializerOptions.Default
})
Proposed solution: We should make this configuration customizable to allow users to choose whether to use System.Text.Json or another serializer, ensuring more flexibility in Cosmos client setup. This would allow us to standardize serialization while also supporting different use cases.
In the
ChatHistoryRecordclass, we are currently using bothNewtonsoft.JsonandSystem.Text.Jsonfor decorating properties:enmarcha/src/Encamina.Enmarcha.SemanticKernel.Plugins.Chat/Plugins/ChatMessageHistoryRecord.cs
Lines 15 to 17 in 2cfec68
This class is ultimately used to retrieve chat history through the ChatHistoryProvider, which utilizes an
IAsyncRepositoryconfigured with a CosmosDB implementation.The goal is to standardize the JSON serialization to use only
System.Text.Json. To achieve this, changes would be needed in the Cosmos client initialization to support this configuration.enmarcha/src/Encamina.Enmarcha.Data.Cosmos/CosmosInitializer.cs
Lines 39 to 41 in 2cfec68
Current approach: To enable System.Text.Json in the Cosmos client today, it can be configured as follows:
Proposed solution: We should make this configuration customizable to allow users to choose whether to use
System.Text.Jsonor another serializer, ensuring more flexibility in Cosmos client setup. This would allow us to standardize serialization while also supporting different use cases.