Semantic Kernel Version 1.0.1

139 Views Asked by At

The latest version of Microsoft.SemanticKernel 1.0.1 is not supporting SKContext and SK Function Attribute. How to migrate from SK Context to Latest Version of 1.0.1.

How to migrate from SK Context to Latest Version of 1.0.1. Sample Code:

[SKFunction, SKName(nameof(Query)), Description("Request Process")]
public async Task <SKContext> ProcessRequest(SKContext context)
{
    //Migration Code here
}
1

There are 1 best solutions below

0
On

Basically, SKFunction became KernelFunction and SKContext was renamed to KernelArguments. The first one is straightforward renaming, and if you want to explore more in-depth why and how SKContext turned into KernelArguments, you should explore the commits from the dotnet-1.0.0-rc1 release. I selected some of them:

I recommend taking a look at the kernel syntax examples here. They use KernelFunction and KernelArguments. Example:

[KernelFunction]
[Description("Send email")]
public string SendEmail(
    [Description("target email addresses")]
    string emailAddresses,
    [Description("answer, which is going to be the email content")]
    string answer,
    KernelArguments arguments)
    {
    var contract = new Email()
    {
        Address = emailAddresses,
        Content = answer,
    };

    // for demo purpose only
    string emailPayload = JsonSerializer.Serialize(contract, this._serializerOptions);
    arguments["email"] = emailPayload;

    return "Here's the API contract I will post to mail server: " + emailPayload;
}

Finally, with want an example of an application using those abstractions, you should check the chat-copilot project.