diff --git a/src/libs/Directory.Build.props b/src/libs/Directory.Build.props index 29e622cb..0bf1a808 100755 --- a/src/libs/Directory.Build.props +++ b/src/libs/Directory.Build.props @@ -16,7 +16,7 @@ - 2.0.7 + 2.0.8 true true tryAGI and contributors diff --git a/src/libs/OpenAI/Client/Extensions/StringExtensions.cs b/src/libs/OpenAI/Client/Extensions/StringExtensions.cs index efac902a..cf167329 100644 --- a/src/libs/OpenAI/Client/Extensions/StringExtensions.cs +++ b/src/libs/OpenAI/Client/Extensions/StringExtensions.cs @@ -39,7 +39,13 @@ public static StringContent ToJsonStringContent(this string json, bool debug) Console.WriteLine(json); } - return new StringContent(json, OpenAIClient.DefaultEncoding, jsonContent); + var content = new StringContent(json, OpenAIClient.DefaultEncoding, jsonContent); + if (OpenAIClient.RemoveCharSetFromContentType) + { + content.Headers.ContentType.CharSet = string.Empty; + } + + return content; } public static string ToSnakeCase(string @string) diff --git a/src/libs/OpenAI/Client/OpenAIClient.cs b/src/libs/OpenAI/Client/OpenAIClient.cs index c03431f0..e1e7d62d 100644 --- a/src/libs/OpenAI/Client/OpenAIClient.cs +++ b/src/libs/OpenAI/Client/OpenAIClient.cs @@ -29,10 +29,15 @@ namespace OpenAI public sealed class OpenAIClient : IDisposable { /// - /// + /// Default encoding to use when making calls to the API. /// public static Encoding? DefaultEncoding { get; set; } = Encoding.UTF8; + /// + /// Remove the charset from the content type. + /// + public static bool RemoveCharSetFromContentType { get; set; } + /// /// Creates a new entry point to the OpenAPI API, handling auth and allowing access to the various API endpoints ///