From f4aac7ddd83394b773b5b122439a2d859c1cc81e Mon Sep 17 00:00:00 2001 From: Chris Rickman Date: Tue, 2 Jul 2024 16:06:58 -0700 Subject: [PATCH] Fix merge --- dotnet/src/Agents/Core/ChatCompletionAgent.cs | 8 +++----- .../Core/Logging/ChatCompletionAgentLogMessages.cs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dotnet/src/Agents/Core/ChatCompletionAgent.cs b/dotnet/src/Agents/Core/ChatCompletionAgent.cs index f30547c2a539..990154b139e4 100644 --- a/dotnet/src/Agents/Core/ChatCompletionAgent.cs +++ b/dotnet/src/Agents/Core/ChatCompletionAgent.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Threading; +using System.Threading.Tasks; using Microsoft.SemanticKernel.ChatCompletion; namespace Microsoft.SemanticKernel.Agents; @@ -72,7 +73,7 @@ public sealed class ChatCompletionAgent : ChatHistoryKernelAgent int messageCount = chat.Count; - this.Logger.LogDebug("[{MethodName}] Invoking {ServiceType}.", nameof(InvokeAsync), chatCompletionService.GetType()); + this.Logger.LogAgentChatServiceInvokingAgent(nameof(InvokeAsync), this.Id, chatCompletionService.GetType()); IAsyncEnumerable messages = chatCompletionService.GetStreamingChatMessageContentsAsync( @@ -81,10 +82,7 @@ public sealed class ChatCompletionAgent : ChatHistoryKernelAgent this.Kernel, cancellationToken); - if (this.Logger.IsEnabled(LogLevel.Information)) - { - this.Logger.LogInformation("[{MethodName}] Invoked {ServiceType} with streaming messages.", nameof(InvokeAsync), chatCompletionService.GetType()); - } + this.Logger.LogAgentChatServiceInvokedStreamingAgent(nameof(InvokeAsync), this.Id, chatCompletionService.GetType()); // Capture mutated messages related function calling / tools for (int messageIndex = messageCount; messageIndex < chat.Count; messageIndex++) diff --git a/dotnet/src/Agents/Core/Logging/ChatCompletionAgentLogMessages.cs b/dotnet/src/Agents/Core/Logging/ChatCompletionAgentLogMessages.cs index d98a6ee9cf91..bb3e69bbcd13 100644 --- a/dotnet/src/Agents/Core/Logging/ChatCompletionAgentLogMessages.cs +++ b/dotnet/src/Agents/Core/Logging/ChatCompletionAgentLogMessages.cs @@ -41,4 +41,17 @@ internal static partial class ChatCompletionAgentLogMessages string agentId, Type serviceType, int messageCount); + + /// + /// Logs invoked streaming agent (complete). + /// + [LoggerMessage( + EventId = 0, + Level = LogLevel.Information, + Message = "[{MethodName}] Agent #{AgentId} Invoked service {ServiceType}.")] + public static partial void LogAgentChatServiceInvokedStreamingAgent( + this ILogger logger, + string methodName, + string agentId, + Type serviceType); }