From 184255acfd4a2b4c0a8844ced84ad4209832be65 Mon Sep 17 00:00:00 2001 From: Krzysztof <60486987+Krzysztof318@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:34:22 +0100 Subject: [PATCH] .Net: Fixed KeyNotFoundExeption in Example09. (#4388) Added KernelFunction attribute to method TaskInjectingCultureInfoOrIFormatProviderWithStringResult ### Motivation and Context Example09 throws KeyNotFoundException. ### Description ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone :smile: --- .../samples/KernelSyntaxExamples/Example09_FunctionTypes.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dotnet/samples/KernelSyntaxExamples/Example09_FunctionTypes.cs b/dotnet/samples/KernelSyntaxExamples/Example09_FunctionTypes.cs index 36517c3c25b0..ec872c21dadf 100644 --- a/dotnet/samples/KernelSyntaxExamples/Example09_FunctionTypes.cs +++ b/dotnet/samples/KernelSyntaxExamples/Example09_FunctionTypes.cs @@ -52,8 +52,8 @@ public static async Task RunAsync() await kernel.InvokeAsync(plugin[nameof(LocalExamplePlugin.TaskInjectingKernelWithInputTextAndStringResult)], new() { - ["textToSummarize"] = @"C# is a modern, versatile language by Microsoft, blending the efficiency of C++ - with Visual Basic's simplicity. It's ideal for a wide range of applications, + ["textToSummarize"] = @"C# is a modern, versatile language by Microsoft, blending the efficiency of C++ + with Visual Basic's simplicity. It's ideal for a wide range of applications, emphasizing type safety, modularity, and modern programming paradigms." }); @@ -238,6 +238,7 @@ public async Task TaskInjectingServiceSelectorWithStringResult(Kernel ke /// /// Example how to inject CultureInfo or IFormatProvider in your function /// + [KernelFunction] public async Task TaskInjectingCultureInfoOrIFormatProviderWithStringResult(CultureInfo cultureInfo, IFormatProvider formatProvider) { var result = $"Culture Name: {cultureInfo.Name}, FormatProvider Equals CultureInfo?: {formatProvider.Equals(cultureInfo)}";