Skip to content

Commit

Permalink
Address code rveiew feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
markwallace-microsoft committed Jul 22, 2024
1 parent 0ffaf31 commit ccc0b2d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
50 changes: 27 additions & 23 deletions dotnet/samples/Concepts/Plugins/TransformPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,33 @@ public string GetFavoriteAnimal([Description("Email address of the user.")] stri
{
if (email.Equals("bob@contoso.com", StringComparison.OrdinalIgnoreCase))
{
switch (animalType)
{
case AnimalType.Mammals: return "Dog";
case AnimalType.Birds: return "Sparrow";
case AnimalType.Reptiles: return "Lizard";
case AnimalType.Amphibians: return "Salamander";
case AnimalType.Fish: return "Tuna";
case AnimalType.Invertebrates: return "Spider";
}
return GetBobsFavoriteAnimal(animalType);
}

switch (animalType)
{
case AnimalType.Mammals: return "Horse";
case AnimalType.Birds: return "Eagle";
case AnimalType.Reptiles: return "Snake";
case AnimalType.Amphibians: return "Frog";
case AnimalType.Fish: return "Shark";
case AnimalType.Invertebrates: return "Ant";
}

return "Unknown";
return GetDefaultFavoriteAnimal(animalType);
}

private string GetBobsFavoriteAnimal(AnimalType animalType) => animalType switch
{
AnimalType.Mammals => "Dog",
AnimalType.Birds => "Sparrow",
AnimalType.Reptiles => "Lizard",
AnimalType.Amphibians => "Salamander",
AnimalType.Fish => "Tuna",
AnimalType.Invertebrates => "Spider",
_ => throw new ArgumentOutOfRangeException(nameof(animalType), $"Unexpected animal type: {animalType}"),
};

private string GetDefaultFavoriteAnimal(AnimalType animalType) => animalType switch
{
AnimalType.Mammals => "Horse",
AnimalType.Birds => "Eagle",
AnimalType.Reptiles => "Snake",
AnimalType.Amphibians => "Frog",
AnimalType.Fish => "Shark",
AnimalType.Invertebrates => "Ant",
_ => throw new ArgumentOutOfRangeException(nameof(animalType), $"Unexpected animal type: {animalType}"),
};
}

[JsonConverter(typeof(JsonStringEnumConverter))]
Expand Down Expand Up @@ -124,9 +128,9 @@ public async Task CreatePluginWithAlteredParametersAsync()
Console.WriteLine(await kernel.InvokePromptAsync("What is my favourite creepy crawly?", new(settings)));

// Example response
// Your favorite color is green.
// Your favorite cold - blooded animal is a lizard.
// Your favorite marine animal is the Tuna.
// Your favorite color is Green. 🌿
// Your favorite cold-blooded animal is a lizard.
// Your favorite marine animal is the Tuna. 🐟
// Your favorite creepy crawly is a spider! 🕷️
}

Expand Down
1 change: 1 addition & 0 deletions dotnet/samples/Concepts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Down below you can find the code snippets that demonstrate the usage of many Sem
- [DescribeAllPluginsAndFunctions](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Plugins/DescribeAllPluginsAndFunctions.cs)
- [GroundednessChecks](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Plugins/GroundednessChecks.cs)
- [ImportPluginFromGrpc](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Plugins/ImportPluginFromGrpc.cs)
- [TransformPlugin](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Plugins/TransformPlugin.cs)

## PromptTemplates - Using [`Templates`](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/PromptTemplate/IPromptTemplate.cs) with parametrization for `Prompt` rendering

Expand Down

0 comments on commit ccc0b2d

Please sign in to comment.