Skip to content

Standardize JSON Serialization in ChatHistoryRecord to Use Only System.Text.Json #147

Description

@LuisM000

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions