diff --git a/dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/Models/OpenAIModel.cs b/dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/Models/OpenAIModel.cs index cbe133683..c7336c5ba 100644 --- a/dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/Models/OpenAIModel.cs +++ b/dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/AI/Models/OpenAIModel.cs @@ -28,6 +28,11 @@ public class OpenAIModel : IPromptCompletionModel private readonly OpenAIClient _openAIClient; private string _deploymentName; + private static JsonSerializerOptions _serializerOptions = new() + { + WriteIndented = true, + Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; private static readonly string _userAgent = "AlphaWave"; @@ -190,12 +195,12 @@ public async Task CompletePromptAsync(ITurnContext turnContext, _logger.LogTrace($"duration {(DateTime.UtcNow - startTime).TotalMilliseconds} ms"); if (promptResponse.Status == PromptResponseStatus.Success) { - _logger.LogTrace(JsonSerializer.Serialize(completionsResponse!.Value)); + _logger.LogTrace(JsonSerializer.Serialize(completionsResponse!.Value, _serializerOptions)); } if (promptResponse.Status == PromptResponseStatus.RateLimited) { _logger.LogTrace("HEADERS:"); - _logger.LogTrace(JsonSerializer.Serialize(rawResponse.Headers)); + _logger.LogTrace(JsonSerializer.Serialize(rawResponse.Headers, _serializerOptions)); } } @@ -221,7 +226,7 @@ public async Task CompletePromptAsync(ITurnContext turnContext, { // TODO: Colorize _logger.LogTrace("CHAT PROMPT:"); - _logger.LogTrace(JsonSerializer.Serialize(prompt.Output)); + _logger.LogTrace(JsonSerializer.Serialize(prompt.Output, _serializerOptions)); } // Call chat completion API @@ -269,12 +274,12 @@ public async Task CompletePromptAsync(ITurnContext turnContext, _logger.LogTrace($"duration {(DateTime.UtcNow - startTime).TotalMilliseconds} ms"); if (promptResponse.Status == PromptResponseStatus.Success) { - _logger.LogTrace(JsonSerializer.Serialize(chatCompletionsResponse!.Value)); + _logger.LogTrace(JsonSerializer.Serialize(chatCompletionsResponse!.Value, _serializerOptions)); } if (promptResponse.Status == PromptResponseStatus.RateLimited) { _logger.LogTrace("HEADERS:"); - _logger.LogTrace(JsonSerializer.Serialize(rawResponse.Headers)); + _logger.LogTrace(JsonSerializer.Serialize(rawResponse.Headers, _serializerOptions)); } } diff --git a/dotnet/samples/.workflows/build-samples.sh b/dotnet/samples/.workflows/build-samples.sh index ad96a64aa..1013d68ae 100644 --- a/dotnet/samples/.workflows/build-samples.sh +++ b/dotnet/samples/.workflows/build-samples.sh @@ -63,7 +63,7 @@ dotnet nuget locals global-packages -c # If var is empty, conditions is true if [ -z $SAMPLE_FOLDER ]; then - for p in $(find . -name "*.csproj"); do dotnet build $p; done + for p in $(find . -name "*.csproj"); do dotnet build -c Debug $p; done else dotnet build $SAMPLE_FOLDER; fi