Skip to content

Commit

Permalink
.Net: Tweak temp function names created by Kernel.InvokePrompt{Stream…
Browse files Browse the repository at this point in the history
…ing}Async (#6108)

These show up in logging.
  • Loading branch information
stephentoub committed May 3, 2024
1 parent 8f15f3a commit 65bb59d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private async Task<PromptRenderingResult> RenderPromptAsync(Kernel kernel, Kerne
}

/// <summary>Create a random, valid function name.</summary>
private static string CreateRandomFunctionName() => $"func{Guid.NewGuid():N}";
internal static string CreateRandomFunctionName(string? prefix = "Function") => $"{prefix}_{Guid.NewGuid():N}";

/// <summary>
/// Captures usage details, including token information.
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/SemanticKernel.Core/KernelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ public static IKernelBuilderPlugins AddFromFunctions(this IKernelBuilderPlugins

KernelFunction function = KernelFunctionFromPrompt.Create(
promptTemplate,
functionName: KernelFunctionFromPrompt.CreateRandomFunctionName(nameof(InvokePromptAsync)),
templateFormat: templateFormat,
promptTemplateFactory: promptTemplateFactory,
loggerFactory: kernel.LoggerFactory);
Expand Down Expand Up @@ -699,6 +700,7 @@ public static IKernelBuilderPlugins AddFromFunctions(this IKernelBuilderPlugins

KernelFunction function = KernelFunctionFromPrompt.Create(
promptTemplate,
functionName: KernelFunctionFromPrompt.CreateRandomFunctionName(nameof(InvokePromptAsync)),
templateFormat: templateFormat,
promptTemplateFactory: promptTemplateFactory,
loggerFactory: kernel.LoggerFactory);
Expand Down Expand Up @@ -775,6 +777,7 @@ public static IKernelBuilderPlugins AddFromFunctions(this IKernelBuilderPlugins

KernelFunction function = KernelFunctionFromPrompt.Create(
promptTemplate,
functionName: KernelFunctionFromPrompt.CreateRandomFunctionName(nameof(InvokePromptStreamingAsync)),
templateFormat: templateFormat,
promptTemplateFactory: promptTemplateFactory,
loggerFactory: kernel.LoggerFactory);
Expand Down Expand Up @@ -815,6 +818,7 @@ public static IKernelBuilderPlugins AddFromFunctions(this IKernelBuilderPlugins

KernelFunction function = KernelFunctionFromPrompt.Create(
promptTemplate,
functionName: KernelFunctionFromPrompt.CreateRandomFunctionName(nameof(InvokePromptStreamingAsync)),
templateFormat: templateFormat,
promptTemplateFactory: promptTemplateFactory,
loggerFactory: kernel.LoggerFactory);
Expand Down

0 comments on commit 65bb59d

Please sign in to comment.