Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions examples/semantic-kernel/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@

import dotnet from 'node-api-dotnet';
import './bin/Microsoft.SemanticKernel.Core.js';
import './bin/Microsoft.SemanticKernel.Functions.Semantic.js';
import './bin/Microsoft.SemanticKernel.Connectors.AI.OpenAI.js';

// The PromptTemplateEngine assembly must be explicitly loaded here, because
// SK KernelBuilder uses Assembly.Load() to load it, and that is not detected
// by the JS exporter.
import './bin/Microsoft.SemanticKernel.TemplateEngine.PromptTemplateEngine.js';

const SK = dotnet.Microsoft.SemanticKernel;
const Logging = dotnet.Microsoft.Extensions.Logging;

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

// The JS marshaller does not yet support extension methods.
const summaryFunction = SK.InlineFunctionsDefinitionExtension
const summaryFunction = SK.KernelSemanticFunctionExtensions
.CreateSemanticFunction(kernel, skPrompt);

const summary = await SK.SKFunctionExtensions.InvokeAsync(summaryFunction, textToSummarize);
const summary = await SK.SKFunctionExtensions.InvokeAsync(
summaryFunction, textToSummarize, kernel);

console.log(summary.toString());
2 changes: 1 addition & 1 deletion examples/semantic-kernel/semantic-kernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.0.0-beta2" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.4.*-*" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions src/NodeApi.DotNetHost/JSMarshaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ internal static bool IsConvertedType(Type type)
}

if (type.IsGenericTypeDefinition &&
(type == typeof(Task<>) ||
type == typeof(CancellationToken) ||
(type == typeof(CancellationToken) ||
type == typeof(IEnumerable<>) ||
type == typeof(IAsyncEnumerable<>) ||
type == typeof(ICollection<>) ||
Expand Down
3 changes: 3 additions & 0 deletions src/NodeApi.DotNetHost/TypeExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ void ExportTypeIfSupported(Type dependencyType)
{
Type genericTypeDefinition = dependencyType.GetGenericTypeDefinition();
if (genericTypeDefinition == typeof(Nullable<>) ||
genericTypeDefinition == typeof(Task<>) ||
genericTypeDefinition.Namespace == typeof(IList<>).Namespace)
{
foreach (Type typeArg in dependencyType.GetGenericArguments())
Expand Down Expand Up @@ -217,6 +218,8 @@ void ExportTypeIfSupported(Type dependencyType)
{
ExportTypeIfSupported(interfaceMethodParameter.ParameterType);
}

ExportTypeIfSupported(interfaceMethod.ReturnType);
}
}
}
Expand Down