Created
June 11, 2024 21:37
-
-
Save xximjasonxx/61ad900c34e02be41ea4a6a7acce9d18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using Microsoft.SemanticKernel; | |
namespace FactorialAdder.Plugins | |
{ | |
public sealed class MathPlugin | |
{ | |
[KernelFunction("factorial"), Description("Calculates the factorial of a number")] | |
public static int Factorial( | |
[Description("The number to get the factorial of")]int number) | |
{ | |
int result = 1; | |
while (number > 1) | |
{ | |
result *= number--; | |
} | |
return result; | |
} | |
[KernelFunction("add"), Description("Adds two numbers")] | |
public static int Add( | |
[Description("The first number to add")]int numberOne, | |
[Description("The second number to add")]int numberTwo) | |
{ | |
return numberOne + numberTwo; | |
} | |
[KernelFunction("subtract10"), Description("Subtracts 10 from a number")] | |
public static int Subtract10( | |
[Description("The number to subtract 10 from")]int number) | |
{ | |
return number - 10; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment