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

Python: all plugins set initialization parameters #10765

Open
sophialagerkranspandey opened this issue Mar 3, 2025 · 0 comments
Open

Python: all plugins set initialization parameters #10765

sophialagerkranspandey opened this issue Mar 3, 2025 · 0 comments
Assignees
Labels
python Pull requests for the Python Semantic Kernel

Comments

@sophialagerkranspandey
Copy link
Contributor

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!

🙇‍

@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel triage labels Mar 3, 2025
@github-actions github-actions bot changed the title all plugins set initialization parameters Python: all plugins set initialization parameters Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

No branches or pull requests

3 participants