Skip to content

Commit

Permalink
Fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
crickman committed Jul 2, 2024
1 parent bcf9e34 commit f4aac7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 3 additions & 5 deletions dotnet/src/Agents/Core/ChatCompletionAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<StreamingChatMessageContent> messages =
chatCompletionService.GetStreamingChatMessageContentsAsync(
Expand All @@ -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++)
Expand Down
13 changes: 13 additions & 0 deletions dotnet/src/Agents/Core/Logging/ChatCompletionAgentLogMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,17 @@ internal static partial class ChatCompletionAgentLogMessages
string agentId,
Type serviceType,
int messageCount);

/// <summary>
/// Logs <see cref="ChatCompletionAgent"/> invoked streaming agent (complete).
/// </summary>
[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);
}

0 comments on commit f4aac7d

Please sign in to comment.