forked from MicrosoftDocs/semantic-kernel-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55aa203
commit dc7d820
Showing
8 changed files
with
270 additions
and
431 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "11-Planner", "11-Planner.csproj", "{FD18937D-8AA6-4EEC-926D-C288FF848F63}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{FD18937D-8AA6-4EEC-926D-C288FF848F63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FD18937D-8AA6-4EEC-926D-C288FF848F63}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FD18937D-8AA6-4EEC-926D-C288FF848F63}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FD18937D-8AA6-4EEC-926D-C288FF848F63}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {C6F0D9F7-FAC3-4F32-A7C1-3632F9CCAE5A} | ||
EndGlobalSection | ||
EndGlobal |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.ComponentModel; | ||
using Microsoft.SemanticKernel; | ||
|
||
namespace Plugins; | ||
|
||
public class MathPlugin | ||
{ | ||
[KernelFunction, Description("Take the square root of a number")] | ||
public static double Sqrt( | ||
[Description("The number to take a square root of")] double number1 | ||
) | ||
{ | ||
return Math.Sqrt(number1); | ||
} | ||
|
||
[KernelFunction, Description("Add two numbers")] | ||
public static double Add( | ||
[Description("The first number to add")] double number1, | ||
[Description("The second number to add")] double number2 | ||
) | ||
{ | ||
return number1 + number2; | ||
} | ||
|
||
[KernelFunction, Description("Subtract two numbers")] | ||
public static double Subtract( | ||
[Description("The first number to subtract from")] double number1, | ||
[Description("The second number to subtract away")] double number2 | ||
) | ||
{ | ||
return number1 - number2; | ||
} | ||
|
||
[KernelFunction, Description("Multiply two numbers. When increasing by a percentage, don't forget to add 1 to the percentage.")] | ||
public static double Multiply( | ||
[Description("The first number to multiply")] double number1, | ||
[Description("The second number to multiply")] double number2 | ||
) | ||
{ | ||
return number1 * number2; | ||
} | ||
|
||
[KernelFunction, Description("Divide two numbers")] | ||
public static double Divide( | ||
[Description("The first number to divide from")] double number1, | ||
[Description("The second number to divide by")] double number2 | ||
) | ||
{ | ||
return number1 / number2; | ||
} | ||
} |
51 changes: 0 additions & 51 deletions
51
samples/dotnet/11-Planner/plugins/MathPlugin/MathPlugin.cs
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.ComponentModel; | ||
using Json.More; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.SemanticKernel; | ||
using Microsoft.SemanticKernel.Planning.Handlebars; | ||
|
||
namespace Plugins; | ||
|
||
public class MathSolver | ||
{ | ||
private readonly ILogger _logger; | ||
|
||
public MathSolver(ILoggerFactory loggerFactory) | ||
{ | ||
this._logger = loggerFactory.CreateLogger<MathSolver>(); | ||
} | ||
|
||
[KernelFunction] | ||
[Description("Solves a math problem.")] | ||
[return: Description("The solution to the math problem.")] | ||
public async Task<string> SolveAsync( | ||
Kernel kernel, | ||
[Description("The math problem to solve; describe it in 2-3 sentences to ensure full context is provided")] string problem | ||
) | ||
{ | ||
var kernelWithMath = kernel.Clone(); | ||
kernelWithMath.Plugins.AddFromType<MathPlugin>(); | ||
|
||
var planner = new HandlebarsPlanner(new HandlebarsPlannerOptions() { AllowLoops = true }); | ||
|
||
// Create a plan | ||
var plan = await planner.CreatePlanAsync(kernelWithMath, problem); | ||
this._logger.LogInformation($"Plan: {plan}"); | ||
|
||
// Execute the plan | ||
var result = (await plan.InvokeAsync(kernelWithMath, [])).Trim(); | ||
this._logger.LogInformation($"Results: {result}"); | ||
|
||
return result; | ||
} | ||
} |
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
Oops, something went wrong.