Skip to content

Commit

Permalink
.Net: Fixed KeyNotFoundExeption in Example09. (#4388)
Browse files Browse the repository at this point in the history
Added KernelFunction attribute to method
TaskInjectingCultureInfoOrIFormatProviderWithStringResult

### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Example09 throws KeyNotFoundException.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [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 😄
  • Loading branch information
Krzysztof318 authored Jan 9, 2024
1 parent 0b3e542 commit 184255a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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."
});

Expand Down Expand Up @@ -238,6 +238,7 @@ public async Task<string> TaskInjectingServiceSelectorWithStringResult(Kernel ke
/// <summary>
/// Example how to inject CultureInfo or IFormatProvider in your function
/// </summary>
[KernelFunction]
public async Task<string> TaskInjectingCultureInfoOrIFormatProviderWithStringResult(CultureInfo cultureInfo, IFormatProvider formatProvider)
{
var result = $"Culture Name: {cultureInfo.Name}, FormatProvider Equals CultureInfo?: {formatProvider.Equals(cultureInfo)}";
Expand Down

0 comments on commit 184255a

Please sign in to comment.