Description
Discussed in #10750
Originally posted by nblog March 3, 2025
Summary
I am using Python and I add plugins through directories because I need to use nativecli
for RPC calls in various Managers. I would like to know if it is possible to set self.nativecli
directly for all classes in the NativePlugin
using the following approach:
Current Implementation
Here is an example of how I am currently initializing the WeatherManager
class within NativePlugin
:
class WeatherManager:
def __init__(self, **kwargs):
self.nativecli: Client = kwargs.get('nativecli', None)
return
@kernel_function(description="...")
def weather(self, location):
return self.nativecli.weather(location)
And this is how I am adding the plugin:
kernel.add_plugin(
parent_directory="plugins", plugin_name="NativePlugin",
class_init_arguments={
"XXXManager": {"nativecli": self.nativecli},
"XXXManager": {"nativecli": self.nativecli},
"XXXManager": {"nativecli": self.nativecli},
...
}
)
Proposed Simplification
I would like to simplify the above approach by using a wildcard to set self.nativecli
for all classes in NativePlugin
. Here is the proposed implementation:
kernel.add_plugin(
parent_directory="plugins", plugin_name="NativePlugin",
class_init_arguments={
"*": {"nativecli": self.nativecli},
}
)
Question
Is the proposed wildcard approach feasible for setting self.nativecli
for all classes in NativePlugin
? If not, do you have any better suggestions for achieving this simplification?
Thank you for your assistance!
🙇
Metadata
Metadata
Assignees
Type
Projects
Status