.Net: Import plugins with mixed prompt and native functions (avoiding creating a plugin for each function) #8851
Labels
kernel.core
.NET
Issue or Pull requests regarding .NET code
sk team issue
A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)
Discussed in #8818
Originally posted by gsubiran September 16, 2024
Hey! I've been working with SK for some time, and I'm having a bit of trouble handling the import of plugin functions. Here's what I've encountered:
When you want to import a plugin with prompt functions (formerly known as semantic functions), you can use:
On the other hand, if you want to import a plugin with native functions, a simple way to do that is:
That’s pretty straightforward. However, the problem arises when you want to combine native and prompt functions in the same plugin. I found that there is no easy way to do this. Additionally, if you want to separate native functions into different classes, you end up creating a new plugin for each native function due to the same issue.
I’d appreciate some advice if I’m missing something here, but I believe the goal of plugins should be to group related native and semantic functions.
My Approach
I created a class called CustomKernelExtensions to make it easier to import both native and prompt functions into the same plugin by calling:
(For simplicity, assume CustomKernelExtensions.cs is placed in the "Plugins" directory, and the plugin name must match the specific plugin folder name.)
Here’s the code for the CustomKernelExtensions class:
Does anyone have any feedback on this approach? I’m wondering if I’m overcomplicating things. Is there a simpler way to achieve the same result? I would appreciate any insights or suggestions!
The text was updated successfully, but these errors were encountered: