Closed rvinothrajendran closed 6 months ago
ImportPluginFromObject uses all public methods on the object, regardless of what interfaces those methods may also satisfy.
While it may make sense from a plugin perspective, as a developer using the API, it can be quite confusing. It might be clearer not to allow objects created by the interface and perhaps throw an exception in such cases.
Even if we wanted that to be the behavior, it's simply not possible. You haven't communicated to the API what interface you care about (because the API doesn't make it possible). The signature of the method takes object target, string? pluginName
, and from its perspective you've simply given it a System.Object and a name to use for the plugin. It doesn't know the type of the local variable the object happened to be referenced by, and the object implements multiple interfaces.
The behavior you're asking for would need to be some new API that was specifically focused on interfaces and that accepted the necessary information to make it possible to narrow down the scope of the reflection.
All ImportPluginFromObject is is a thin wrapper around CreatePluginFromFunctions and use of reflection to get the functions to wrap. You can do the same thing if you want to write such a helper yourself.
Certainly, I grasp the concept behind the functions, and it's a sound recommendation to establish a new API for interface support. In the interim, I've generated a community NuGet package to aid in implementing "ImportPluginFromInterface." https://www.nuget.org/packages/AzureAI.Community.Microsoft.Semantic.Kernel.PlugIn.Interface 😎
This issue is stale because it has been open for 90 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Describe the bug A class inherits from both
Interface1
andInterface2
. In theImportPluginFromObject
method, when I pass anInterface1
object to the function and inspect the plugin functions, I observe that it includes details from both interfaces.To Reproduce Steps to reproduce the behavior: Follow the steps
Define the plugins
ImportPluginFromObject
Expected behavior
Import only Interface1 Objects in the Plugin Function Inspection
Platform