diff --git a/OpenAI-DotNet-Tests/TestFixture_08_Files.cs b/OpenAI-DotNet-Tests/TestFixture_08_Files.cs index 44d3ef14..0916e737 100644 --- a/OpenAI-DotNet-Tests/TestFixture_08_Files.cs +++ b/OpenAI-DotNet-Tests/TestFixture_08_Files.cs @@ -15,7 +15,7 @@ public async Task Test_01_UploadFile() { Assert.IsNotNull(OpenAIClient.FilesEndpoint); var testData = new Conversation(new List { new Message(Role.Assistant, "I'm a learning language model") }); - await File.WriteAllTextAsync("test.jsonl", JsonSerializer.Serialize(testData, OpenAIClient.DefaultJsonSerializerOptions)); + await File.WriteAllTextAsync("test.jsonl", JsonSerializer.Serialize(testData, OpenAIClient.JsonSerializationOptions)); Assert.IsTrue(File.Exists("test.jsonl")); var result = await OpenAIClient.FilesEndpoint.UploadFileAsync("test.jsonl", "fine-tune"); Assert.IsNotNull(result); diff --git a/OpenAI-DotNet-Tests/TestFixture_09_FineTuning.cs b/OpenAI-DotNet-Tests/TestFixture_09_FineTuning.cs index 5944879c..27fdd7e0 100644 --- a/OpenAI-DotNet-Tests/TestFixture_09_FineTuning.cs +++ b/OpenAI-DotNet-Tests/TestFixture_09_FineTuning.cs @@ -80,7 +80,7 @@ private async Task CreateTestTrainingDataAsync() }) }; const string localTrainingDataPath = "fineTunesTestTrainingData.jsonl"; - await File.WriteAllLinesAsync(localTrainingDataPath, conversations.Select(conversation => JsonSerializer.Serialize(conversation, OpenAIClient.DefaultJsonSerializerOptions))); + await File.WriteAllLinesAsync(localTrainingDataPath, conversations.Select(conversation => JsonSerializer.Serialize(conversation, OpenAIClient.JsonSerializationOptions))); var fileData = await OpenAIClient.FilesEndpoint.UploadFileAsync(localTrainingDataPath, "fine-tune"); File.Delete(localTrainingDataPath); Assert.IsFalse(File.Exists(localTrainingDataPath)); diff --git a/OpenAI-DotNet/OpenAI-DotNet.csproj b/OpenAI-DotNet/OpenAI-DotNet.csproj index 3e0733df..c6eba20e 100644 --- a/OpenAI-DotNet/OpenAI-DotNet.csproj +++ b/OpenAI-DotNet/OpenAI-DotNet.csproj @@ -18,8 +18,10 @@ More context [on Roger Pincombe's blog](https://rogerpincombe.com/openai-dotnet- https://github.com/RageAgainstThePixel/OpenAI-DotNet OpenAI, AI, ML, API, gpt-4, gpt-3.5-tubo, gpt-3, chatGPT, chat-gpt, gpt-2, gpt, dall-e-2, dall-e-3 OpenAI API - 7.3.0 - Version 7.3.0 + 7.3.1 + Version 7.3.1 +- Fixed json serialization settings when EnableDebug is disabled +Version 7.3.0 - Added AgentsEndpoint - Added ThreadsEndpoint - Updated ImagesEndpoint return types to ImageResult list diff --git a/OpenAI-DotNet/OpenAIClient.cs b/OpenAI-DotNet/OpenAIClient.cs index af69bb1e..6254d7cf 100644 --- a/OpenAI-DotNet/OpenAIClient.cs +++ b/OpenAI-DotNet/OpenAIClient.cs @@ -107,9 +107,7 @@ private HttpClient SetupClient(HttpClient client = null) /// /// The to use when making calls to the API. /// - internal static JsonSerializerOptions JsonSerializationOptions { get; private set; } = DefaultJsonSerializerOptions; - - internal static JsonSerializerOptions DefaultJsonSerializerOptions { get; } = new JsonSerializerOptions + internal static JsonSerializerOptions JsonSerializationOptions { get; } = new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, Converters = { new JsonStringEnumConverterFactory() } @@ -125,28 +123,10 @@ private HttpClient SetupClient(HttpClient client = null) /// internal OpenAIClientSettings OpenAIClientSettings { get; } - private bool enableDebug; - /// /// Enables or disables debugging for all endpoints. /// - public bool EnableDebug - { - get => enableDebug; - set - { - enableDebug = value; - - JsonSerializationOptions = enableDebug - ? DefaultJsonSerializerOptions - : new JsonSerializerOptions - { - WriteIndented = enableDebug, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - Converters = { new JsonStringEnumConverterFactory() } - }; - } - } + public bool EnableDebug { get; set; } /// /// List and describe the various models available in the API.