Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Allow instances of ISKFunction to be used with different Kernel instances #2936

Closed
1 task
Tracked by #3131
markwallace-microsoft opened this issue Sep 22, 2023 · 3 comments
Closed
1 task
Tracked by #3131
Assignees
Labels
sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)
Milestone

Comments

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Sep 22, 2023

Important

Labeled Urgent because it will require a breaking change.

Tasks

Preview Give feedback
@markwallace-microsoft
Copy link
Member Author

The code to register a function with a Kernel is implemented as follows

    public ISKFunction RegisterCustomFunction(ISKFunction customFunction)
    {
        Verify.NotNull(customFunction);

        customFunction.SetDefaultFunctionCollection(this.Functions);
        this._functionCollection.AddFunction(customFunction);

        return customFunction;
    }

The call to customFunction.SetDefaultFunctionCollection(this.Functions) causes the ISKFunction instance to be linked to the current Kernel instance. This means it cannot be reused.

The means we cannot reuse an ISKFunction instance and we have to recreate these. This can be an expensive operation e.g. for semantic functions which rely on a prompt template which will need to be parsed multiple times.

@markwallace-microsoft markwallace-microsoft changed the title Allow instances of ISKFunction to be used with different Kernel instances .Net: Allow instances of ISKFunction to be used with different Kernel instances Sep 22, 2023
@evchaki evchaki added the sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community) label Sep 22, 2023
@markwallace-microsoft markwallace-microsoft removed their assignment Oct 5, 2023
@alliscode alliscode removed the triage label Oct 9, 2023
@markwallace-microsoft markwallace-microsoft added this to the v1.0.0 milestone Oct 10, 2023
@SergeyMenshykh SergeyMenshykh moved this from Sprint: Planned to Sprint: In Progress in Semantic Kernel Oct 10, 2023
@matthewbolanos
Copy link
Member

@alliscode, we'll likely need your help to know if this is a problem needing solving for v1.0.0

@matthewbolanos matthewbolanos modified the milestone: v1.0.0 Oct 12, 2023
@markwallace-microsoft
Copy link
Member Author

This is resolved and the current methods that link a semantic function to a kernel instance are now obsolete

@github-project-automation github-project-automation bot moved this from Sprint: In Progress to Sprint: Done in Semantic Kernel Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)
Projects
Archived in project
Development

No branches or pull requests

6 participants