Skip to content

Commit 80f9cff

Browse files
authored
Update to latest SK version, fix type exporter bug (#161)
1 parent ac15b02 commit 80f9cff

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

examples/semantic-kernel/example.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55

66
import dotnet from 'node-api-dotnet';
77
import './bin/Microsoft.SemanticKernel.Core.js';
8+
import './bin/Microsoft.SemanticKernel.Functions.Semantic.js';
89
import './bin/Microsoft.SemanticKernel.Connectors.AI.OpenAI.js';
910

10-
// The PromptTemplateEngine assembly must be explicitly loaded here, because
11-
// SK KernelBuilder uses Assembly.Load() to load it, and that is not detected
12-
// by the JS exporter.
13-
import './bin/Microsoft.SemanticKernel.TemplateEngine.PromptTemplateEngine.js';
14-
1511
const SK = dotnet.Microsoft.SemanticKernel;
1612
const Logging = dotnet.Microsoft.Extensions.Logging;
1713

@@ -56,9 +52,10 @@ does not conflict with the First or Second Law.
5652
`;
5753

5854
// The JS marshaller does not yet support extension methods.
59-
const summaryFunction = SK.InlineFunctionsDefinitionExtension
55+
const summaryFunction = SK.KernelSemanticFunctionExtensions
6056
.CreateSemanticFunction(kernel, skPrompt);
6157

62-
const summary = await SK.SKFunctionExtensions.InvokeAsync(summaryFunction, textToSummarize);
58+
const summary = await SK.SKFunctionExtensions.InvokeAsync(
59+
summaryFunction, textToSummarize, kernel);
6360

6461
console.log(summary.toString());

examples/semantic-kernel/semantic-kernel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
12+
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta2" />
1313
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
1414
</ItemGroup>
1515

src/NodeApi.DotNetHost/JSMarshaller.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ internal static bool IsConvertedType(Type type)
159159
}
160160

161161
if (type.IsGenericTypeDefinition &&
162-
(type == typeof(Task<>) ||
163-
type == typeof(CancellationToken) ||
162+
(type == typeof(CancellationToken) ||
164163
type == typeof(IEnumerable<>) ||
165164
type == typeof(IAsyncEnumerable<>) ||
166165
type == typeof(ICollection<>) ||

src/NodeApi.DotNetHost/TypeExporter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ void ExportTypeIfSupported(Type dependencyType)
172172
{
173173
Type genericTypeDefinition = dependencyType.GetGenericTypeDefinition();
174174
if (genericTypeDefinition == typeof(Nullable<>) ||
175+
genericTypeDefinition == typeof(Task<>) ||
175176
genericTypeDefinition.Namespace == typeof(IList<>).Namespace)
176177
{
177178
foreach (Type typeArg in dependencyType.GetGenericArguments())
@@ -217,6 +218,8 @@ void ExportTypeIfSupported(Type dependencyType)
217218
{
218219
ExportTypeIfSupported(interfaceMethodParameter.ParameterType);
219220
}
221+
222+
ExportTypeIfSupported(interfaceMethod.ReturnType);
220223
}
221224
}
222225
}

0 commit comments

Comments
 (0)