-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Showing
82 changed files
with
1,182 additions
and
133 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
29 changes: 29 additions & 0 deletions
29
dotnet/src/Extensions/Extensions.UnitTests/Extensions.UnitTests.csproj
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,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<AssemblyName>SemanticKernel.Extensions.UnitTests</AssemblyName> | ||
<RootNamespace>SemanticKernel.Extensions.UnitTests</RootNamespace> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<IsPackable>false</IsPackable> | ||
<NoWarn>CA2007,VSTHRD111</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="Moq" /> | ||
<PackageReference Include="xunit" /> | ||
<PackageReference Include="xunit.runner.visualstudio"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Planning.ActionPlanner\Planning.ActionPlanner.csproj" /> | ||
<ProjectReference Include="..\Planning.SequentialPlanner\Planning.SequentialPlanner.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
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
27 changes: 27 additions & 0 deletions
27
...nsions/Extensions.UnitTests/Planning/SequentialPlanner/TestHelpers/ExceptionExtensions.cs
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,27 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Threading; | ||
|
||
// ReSharper disable once CheckNamespace // Extension methods | ||
namespace System; | ||
|
||
/// <summary> | ||
/// Exception extension methods. | ||
/// </summary> | ||
internal static class ExceptionExtensions | ||
{ | ||
/// <summary> | ||
/// Check if an exception is of a type that should not be caught by the kernel. | ||
/// </summary> | ||
/// <param name="ex">Exception.</param> | ||
/// <returns>True if <paramref name="ex"/> is a critical exception and should not be caught.</returns> | ||
internal static bool IsCriticalException(this Exception ex) | ||
=> ex is OutOfMemoryException | ||
or ThreadAbortException | ||
or AccessViolationException | ||
or AppDomainUnloadedException | ||
or BadImageFormatException | ||
or CannotUnloadAppDomainException | ||
or InvalidProgramException | ||
or StackOverflowException; | ||
} |
6 changes: 2 additions & 4 deletions
6
...Kernel/Planning/FunctionViewExtensions.cs → ...ner/TestHelpers/FunctionViewExtensions.cs
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
56 changes: 56 additions & 0 deletions
56
...nsions/Extensions.UnitTests/Planning/SequentialPlanner/TestHelpers/SKContextExtensions.cs
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,56 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using Microsoft.SemanticKernel.SkillDefinition; | ||
|
||
// ReSharper disable once CheckNamespace - Using NS of SKContext | ||
namespace Microsoft.SemanticKernel.Orchestration; | ||
|
||
internal static class SKContextExtensions | ||
{ | ||
/// <summary> | ||
/// Simple extension method to check if a function is registered in the SKContext. | ||
/// </summary> | ||
/// <param name="context">The SKContext to check</param> | ||
/// <param name="skillName">The skill name</param> | ||
/// <param name="functionName">The function name</param> | ||
/// <param name="registeredFunction">The registered function, if found</param> | ||
internal static bool IsFunctionRegistered(this SKContext context, string skillName, string functionName, out ISKFunction? registeredFunction) | ||
{ | ||
context.ThrowIfSkillCollectionNotSet(); | ||
|
||
if (context.Skills!.HasNativeFunction(skillName, functionName)) | ||
{ | ||
registeredFunction = context.Skills.GetNativeFunction(skillName, functionName); | ||
return true; | ||
} | ||
|
||
if (context.Skills.HasNativeFunction(functionName)) | ||
{ | ||
registeredFunction = context.Skills.GetNativeFunction(functionName); | ||
return true; | ||
} | ||
|
||
if (context.Skills.HasSemanticFunction(skillName, functionName)) | ||
{ | ||
registeredFunction = context.Skills.GetSemanticFunction(skillName, functionName); | ||
return true; | ||
} | ||
|
||
registeredFunction = null; | ||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Ensures the context has a skill collection available | ||
/// </summary> | ||
/// <param name="context">SK execution context</param> | ||
internal static void ThrowIfSkillCollectionNotSet(this SKContext context) | ||
{ | ||
if (context.Skills == null) | ||
{ | ||
throw new KernelException( | ||
KernelException.ErrorCodes.SkillCollectionNotSet, | ||
"Skill collection not found in the context"); | ||
} | ||
} | ||
} |
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.