Skip to content

Commit

Permalink
Upgrade to 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Dec 19, 2023
1 parent f5b657f commit 5ec24fc
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Assistants.Tests/HarnessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Plugins.Core;
using SemanticKernel.Assistants;
using SemanticKernel.Assistants.Tests.Plugins;
using System.Threading.Tasks;
using Xunit.Abstractions;

Expand Down
182 changes: 182 additions & 0 deletions src/Assistants.Tests/Plugins/MathPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
using Microsoft.SemanticKernel;
using System.ComponentModel;

namespace SemanticKernel.Assistants.Tests.Plugins;

/// <summary>
/// MathPlugin provides a set of functions to make Math calculations.
/// </summary>
public sealed class MathPlugin
{
[KernelFunction]
[Description("Adds two numbers. This takes only 2 numbers.")]
[return: Description("The summation of the 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("Subtracts two numbers. This takes only 2 numbers.")]
[return: Description("The difference between the minuend and subtrahend.")]
public static double Subtract(
[Description("The minuend")] double number1,
[Description("The subtrahend")] double number2)
{
return number1 - number2;
}

[KernelFunction]
[Description("Multiplies two numbers. This takes only 2 numbers.")]
[return: Description("The product of the numbers.")]
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("Divides two numbers. This takes only 2 numbers.")]
[return: Description("The quotient of the dividend and divisor.")]
public static double Divide(
[Description("The dividend")] double number1,
[Description("The divisor")] double number2)
{
return number1 / number2;
}

[KernelFunction]
[Description("Gets the remainder of two numbers. This takes only 2 numbers.")]
[return: Description("The remainder of the dividend and divisor.")]
public static double Modulo(
[Description("The dividend")] double number1,
[Description("The divisor")] double number2)
{
return number1 % number2;
}

[KernelFunction]
[Description("Gets the absolute value of a number.")]
[return: Description("The absolute value of the number.")]
public static double Abs(
[Description("The number")] double number1)
{
return System.Math.Abs(number1);
}

[KernelFunction]
[Description("Gets the ceiling of a single number.")]
[return: Description("The ceiling of the number.")]
public static double Ceil(
[Description("The number")] double number1)
{
return System.Math.Ceiling(number1);
}

[KernelFunction]
[Description("Gets the floor of a single number.")]
[return: Description("The floor of the number.")]
public static double Floor(
[Description("The number")] double number1)
{
return System.Math.Floor(number1);
}

[KernelFunction]
[Description("Gets the maximum of two numbers. This takes only 2 numbers.")]
[return: Description("The maximum of the two numbers.")]
public static double Max(
[Description("The first number")] double number1,
[Description("The second number")] double number2)
{
return System.Math.Max(number1, number2);
}

[KernelFunction]
[Description("Gets the minimum of two numbers. This takes only 2 numbers.")]
[return: Description("The minimum of the two numbers.")]
public static double Min(
[Description("The first number")] double number1,
[Description("The second number")] double number2)
{
return System.Math.Min(number1, number2);
}

[KernelFunction]
[Description("Gets the sign of a number.")]
[return: Description("The sign of the number.")]
public static double Sign(
[Description("The number")] double number1)
{
return System.Math.Sign(number1);
}

[KernelFunction]
[Description("Gets the square root of a number.")]
[return: Description("The square root of the number.")]
public static double Sqrt(
[Description("The number")] double number1)
{
return System.Math.Sqrt(number1);
}

[KernelFunction]
[Description("Gets the sine of a number.")]
[return: Description("The sine of the number.")]
public static double Sin(
[Description("The number")] double number1)
{
return System.Math.Sin(number1);
}

[KernelFunction]
[Description("Gets the cosine of a number.")]
[return: Description("The cosine of the number.")]
public static double Cos(
[Description("The number")] double number1)
{
return System.Math.Cos(number1);
}

[KernelFunction]
[Description("Gets the tangent of a number.")]
[return: Description("The tangent of the number.")]
public static double Tan(
[Description("The number")] double number1)
{
return System.Math.Tan(number1);
}

[KernelFunction]
[Description("Raises a number to a power.")]
[return: Description("The number raised to the power.")]
public static double Pow(
[Description("The number")] double number1,
[Description("The power")] double number2)
{
return System.Math.Pow(number1, number2);
}

[KernelFunction]
[Description("Gets the natural logarithm of a number.")]
[return: Description("The natural logarithm of the number.")]
public static double Log(
[Description("The number")] double number1,
[Description("The base of the logarithm")] double number2 = 10)
{
return System.Math.Log(number1, number2);
}

[KernelFunction]
[Description("Gets a rounded number.")]
[return: Description("The rounded number.")]
public static double Round(
[Description("The number")] double number1,
[Description("The number of digits to round to")] int number2 = 0)
{
return System.Math.Round(number1, number2);
}
}
4 changes: 1 addition & 3 deletions src/Assistants.Tests/SemanticKernel.Assistants.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
<NoWarn>CS1591;SKEXP0001;SKEXP0050;SKEXP0060;SKEXP0061</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants);DISABLEHOST</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/Assistants/Extensions/ChatHistoryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static class ChatHistoryExtensions
{
public static void AddFunctionMessage(this ChatHistory chatHistory, string message, string functionName)
{
chatHistory.AddMessage(new("function"), message, metadata: new Dictionary<string, object?>(1) { { OpenAIChatMessageContent.ToolCallsProperty, functionName } });
chatHistory.AddMessage(new("function"), message, metadata: new Dictionary<string, object?>(1) { { OpenAIChatMessageContent.ToolIdProperty, functionName } });
}
}
}
6 changes: 3 additions & 3 deletions src/Assistants/SemanticKernel.Assistants.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-rc4" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.0.0-rc4" />
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.0.0-rc4" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.1" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.0.1" />
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.0.1" />
<PackageReference Include="Microsoft.SemanticKernel.Planners.Handlebars" Version="1.0.0-rc4" />
<PackageReference Include="Microsoft.SemanticKernel.Planners.OpenAI" Version="1.0.0-rc4" />
<PackageReference Include="xunit.extensibility.execution" Version="2.6.3" />
Expand Down

0 comments on commit 5ec24fc

Please sign in to comment.