Skip to content

Commit

Permalink
Improve handlebars planner
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbolanos committed Nov 5, 2023
1 parent 1843352 commit db6436f
Show file tree
Hide file tree
Showing 13 changed files with 503 additions and 133 deletions.
67 changes: 67 additions & 0 deletions core-sk-scenarios.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dotnet", "dotnet", "{CA8DA14E-F551-4B9F-889A-CBA6E4343EC7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{CC6C5BC5-CC1D-4969-91D6-D46AA39A9881}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "03-SimpleRag", "dotnet\samples\03-SimpleRag\03-SimpleRag.csproj", "{4189029E-7D25-40CC-9A9B-2EB8AE915D09}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "01-SimpleChat", "dotnet\samples\01-SimpleChat\01-SimpleChat.csproj", "{7EB80D89-AB99-4E19-9B4A-D635D1B6AE4A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "04-DynamicRag", "dotnet\samples\04-DynamicRag\04-DynamicRag.csproj", "{03845119-78CB-4348-A104-13C446FF3A52}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "02-PersonaChat", "dotnet\samples\02-PersonaChat\02-PersonaChat.csproj", "{D4107740-41E7-4752-9376-DF6B7CB94993}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{13392B8C-9B6C-4A55-81F3-CFF5ACC51576}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "extensions", "extensions", "{2FDE398A-0F01-4210-B80D-BA0F1E220529}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SKHandleBars", "dotnet\src\extensions\SKHandleBars\SKHandleBars.csproj", "{54AE9DFB-C578-4B43-8A63-817384E09780}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4189029E-7D25-40CC-9A9B-2EB8AE915D09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4189029E-7D25-40CC-9A9B-2EB8AE915D09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4189029E-7D25-40CC-9A9B-2EB8AE915D09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4189029E-7D25-40CC-9A9B-2EB8AE915D09}.Release|Any CPU.Build.0 = Release|Any CPU
{7EB80D89-AB99-4E19-9B4A-D635D1B6AE4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EB80D89-AB99-4E19-9B4A-D635D1B6AE4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EB80D89-AB99-4E19-9B4A-D635D1B6AE4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EB80D89-AB99-4E19-9B4A-D635D1B6AE4A}.Release|Any CPU.Build.0 = Release|Any CPU
{03845119-78CB-4348-A104-13C446FF3A52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03845119-78CB-4348-A104-13C446FF3A52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03845119-78CB-4348-A104-13C446FF3A52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03845119-78CB-4348-A104-13C446FF3A52}.Release|Any CPU.Build.0 = Release|Any CPU
{D4107740-41E7-4752-9376-DF6B7CB94993}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4107740-41E7-4752-9376-DF6B7CB94993}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4107740-41E7-4752-9376-DF6B7CB94993}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4107740-41E7-4752-9376-DF6B7CB94993}.Release|Any CPU.Build.0 = Release|Any CPU
{54AE9DFB-C578-4B43-8A63-817384E09780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54AE9DFB-C578-4B43-8A63-817384E09780}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54AE9DFB-C578-4B43-8A63-817384E09780}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54AE9DFB-C578-4B43-8A63-817384E09780}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CC6C5BC5-CC1D-4969-91D6-D46AA39A9881} = {CA8DA14E-F551-4B9F-889A-CBA6E4343EC7}
{4189029E-7D25-40CC-9A9B-2EB8AE915D09} = {CC6C5BC5-CC1D-4969-91D6-D46AA39A9881}
{7EB80D89-AB99-4E19-9B4A-D635D1B6AE4A} = {CC6C5BC5-CC1D-4969-91D6-D46AA39A9881}
{03845119-78CB-4348-A104-13C446FF3A52} = {CC6C5BC5-CC1D-4969-91D6-D46AA39A9881}
{D4107740-41E7-4752-9376-DF6B7CB94993} = {CC6C5BC5-CC1D-4969-91D6-D46AA39A9881}
{13392B8C-9B6C-4A55-81F3-CFF5ACC51576} = {CA8DA14E-F551-4B9F-889A-CBA6E4343EC7}
{2FDE398A-0F01-4210-B80D-BA0F1E220529} = {13392B8C-9B6C-4A55-81F3-CFF5ACC51576}
{54AE9DFB-C578-4B43-8A63-817384E09780} = {2FDE398A-0F01-4210-B80D-BA0F1E220529}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3855C992-1A2D-4E5F-9842-A9015C0AF77C}
EndGlobalSection
EndGlobal
25 changes: 25 additions & 0 deletions dotnet/samples/03-SimpleRag/03-SimpleRag.sln
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}") = "03-SimpleRag", "03-SimpleRag.csproj", "{D158D0FF-6F94-4405-AF2B-26ADC1ACBE3D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D158D0FF-6F94-4405-AF2B-26ADC1ACBE3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D158D0FF-6F94-4405-AF2B-26ADC1ACBE3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D158D0FF-6F94-4405-AF2B-26ADC1ACBE3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D158D0FF-6F94-4405-AF2B-26ADC1ACBE3D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C2757D52-4690-4BA0-9B86-190C362EBF2D}
EndGlobalSection
EndGlobal
5 changes: 3 additions & 2 deletions dotnet/samples/04-DynamicRag/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net6.0/04-DynamicRag.dll",
"program": "${workspaceFolder}/bin/Debug/net7.0/04-DynamicRag.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"stopAtEntry": false
"stopAtEntry": false,
"requireExactSource": false
},
{
"name": ".NET Core Attach",
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/04-DynamicRag/04-DynamicRag.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace></RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
25 changes: 25 additions & 0 deletions dotnet/samples/04-DynamicRag/04-DynamicRag.sln
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}") = "04-DynamicRag", "04-DynamicRag.csproj", "{43BE5D0C-EBA1-4D9E-8CA5-53BDB6B5F4F4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43BE5D0C-EBA1-4D9E-8CA5-53BDB6B5F4F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43BE5D0C-EBA1-4D9E-8CA5-53BDB6B5F4F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43BE5D0C-EBA1-4D9E-8CA5-53BDB6B5F4F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43BE5D0C-EBA1-4D9E-8CA5-53BDB6B5F4F4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {03C276AB-5361-4CE1-9445-4B0248D407FB}
EndGlobalSection
EndGlobal
90 changes: 45 additions & 45 deletions dotnet/samples/04-DynamicRag/Plugins/MathPlugin/Math.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,32 @@ public static async Task<string> PerformMath(
lastPlan = plan;


Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("[Plan]");
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.WriteLine(lastPlan.ToString().Trim());
Console.ResetColor();
// Console.ForegroundColor = ConsoleColor.Blue;
// Console.WriteLine("[Plan]");
// Console.ForegroundColor = ConsoleColor.DarkBlue;
// Console.WriteLine(lastPlan.ToString().Trim());
// Console.ResetColor();

// Run the plan
try {
var result = await plan.InvokeAsync(kernel, new Dictionary<string, object?>());

Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[Result]");
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine(result.ToString().Trim());
Console.ResetColor();
// Console.ForegroundColor = ConsoleColor.Green;
// Console.WriteLine("[Result]");
// Console.ForegroundColor = ConsoleColor.DarkGreen;
// Console.WriteLine(result.ToString().Trim());
// Console.ResetColor();

return result.GetValue<string>()!;
} catch (Exception e) {
// If we get an error, try again
lastError = e;

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[Error]");
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine(e.Message.ToString().Trim());
Console.ResetColor();
// Console.ForegroundColor = ConsoleColor.Red;
// Console.WriteLine("[Error]");
// Console.ForegroundColor = ConsoleColor.DarkRed;
// Console.WriteLine(e.Message.ToString().Trim());
// Console.ResetColor();
}
maxTries--;
}
Expand Down Expand Up @@ -125,15 +125,15 @@ public static double Multiply(
[Description("Divides two numbers.")]
[SKOutputDescription("The quotient of the dividend and divisor.")]
[SKSample(
inputs: "{\"dividend\":10, \"divisor\":2}",
inputs: "{\"number1\":10, \"number2\":2}",
output:"5"
)]
public static double Divide(
[Description("The dividend")] double dividend,
[Description("The divisor")] double divisor
[Description("The dividend")] double number1,
[Description("The divisor")] double number2
)
{
return dividend / divisor;
return number1 / number2;
}

[SKFunction]
Expand All @@ -155,42 +155,42 @@ public static double Modulo(
[Description("Gets the absolute value of a number.")]
[SKOutputDescription("The absolute value of the number.")]
[SKSample(
inputs: "{\"number\":-10}",
inputs: "{\"number1\":-10}",
output:"5"
)]
public static double Abs(
[Description("The number")] double number
[Description("The number")] double number1
)
{
return System.Math.Abs(number);
return System.Math.Abs(number1);
}

[SKFunction]
[Description("Gets the ceiling of a single number.")]
[SKOutputDescription("The ceiling of the number.")]
[SKSample(
inputs: "{\"number\":5.1}",
inputs: "{\"number1\":5.1}",
output:"6"
)]
public static double Ceiling(
[Description("The number")] double number
public static double Ceil(
[Description("The number")] double number1
)
{
return System.Math.Ceiling(number);
return System.Math.Ceiling(number1);
}

[SKFunction]
[Description("Gets the floor of a single number.")]
[SKOutputDescription("The floor of the number.")]
[SKSample(
inputs: "{\"number\":5.9}",
inputs: "{\"number1\":5.9}",
output:"5"
)]
public static double Floor(
[Description("The number")] double number
[Description("The number")] double number1
)
{
return System.Math.Floor(number);
return System.Math.Floor(number1);
}

[SKFunction]
Expand Down Expand Up @@ -227,70 +227,70 @@ public static double Min(
[Description("Gets the sign of a number.")]
[SKOutputDescription("The sign of the number.")]
[SKSample(
inputs: "{\"number\":-10}",
inputs: "{\"number1\":-10}",
output:"-1"
)]
public static double Sign(
[Description("The number")] double number
[Description("The number")] double number1
)
{
return System.Math.Sign(number);
return System.Math.Sign(number1);
}

[SKFunction]
[Description("Gets the square root of a number.")]
[SKOutputDescription("The square root of the number.")]
[SKSample(
inputs: "{\"number\":25}",
inputs: "{\"number1\":25}",
output:"5"
)]
public static double Sqrt(
[Description("The number")] double number
[Description("The number")] double number1
)
{
return System.Math.Sqrt(number);
return System.Math.Sqrt(number1);
}

[SKFunction]
[Description("Gets the sine of a number.")]
[SKOutputDescription("The sine of the number.")]
[SKSample(
inputs: "{\"number\":0}",
inputs: "{\"number1\":0}",
output:"0"
)]
public static double Sin(
[Description("The number")] double number
[Description("The number")] double number1
)
{
return System.Math.Sin(number);
return System.Math.Sin(number1);
}

[SKFunction]
[Description("Gets the cosine of a number.")]
[SKOutputDescription("The cosine of the number.")]
[SKSample(
inputs: "{\"number\":0}",
inputs: "{\"number1\":0}",
output:"1"
)]
public static double Cos(
[Description("The number")] double number
[Description("The number")] double number1
)
{
return System.Math.Cos(number);
return System.Math.Cos(number1);
}

[SKFunction]
[Description("Gets the tangent of a number.")]
[SKOutputDescription("The tangent of the number.")]
[SKSample(
inputs: "{\"number\":0}",
inputs: "{\"number1\":0}",
output:"0"
)]
public static double Tan(
[Description("The number")] double number
[Description("The number")] double number1
)
{
return System.Math.Tan(number);
return System.Math.Tan(number1);
}

[SKFunction]
Expand All @@ -312,7 +312,7 @@ public static double Pow(
[Description("Gets the natural logarithm of a number.")]
[SKOutputDescription("The natural logarithm of the number.")]
[SKSample(
inputs: "{\"number\":10, \"baseNumber\":10}",
inputs: "{\"number1\":10, \"number2\":10}",
output:"2.302585092994046"
)]
public static double Log(
Expand Down
Loading

0 comments on commit db6436f

Please sign in to comment.