Skip to content

Plugin samples using DI #9769

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

Closed
2 tasks
markwallace-microsoft opened this issue Nov 20, 2024 · 1 comment · Fixed by #9794
Closed
2 tasks

Plugin samples using DI #9769

markwallace-microsoft opened this issue Nov 20, 2024 · 1 comment · Fixed by #9794
Assignees
Labels
samples sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)

Comments

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Nov 20, 2024

Create a sample that uses a plugin which depends on a service made available using dependency injection

  • Native function
  • Open API function
@markwallace-microsoft markwallace-microsoft moved this to Sprint: In Progress in Semantic Kernel Nov 20, 2024
@markwallace-microsoft markwallace-microsoft self-assigned this Nov 20, 2024
@markwallace-microsoft markwallace-microsoft added triage sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community) samples and removed triage labels Nov 20, 2024
@RogerBarreto
Copy link
Member

  • Native functions

We do have a sample in the getting started Step (Dependency Injection), injecting ILoggerFactory in a plugin.

public class TimeInformation(ILoggerFactory loggerFactory)

HomeAutomation Demo also uses DI with plugins, injecting plugins within plugins.

builder.Services.AddSingleton<MyTimePlugin>();

and here

public class MyAlarmPlugin(MyTimePlugin timePlugin)

github-merge-queue bot pushed a commit that referenced this issue Nov 25, 2024
### Motivation and Context

Create samples that uses a plugin which depends on a service made
available using dependency injection
- Native function
- Open API function

Closes #9769 

### Description

A frequent ask is how to inject a service using DI which will be used
during function execution.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
@github-project-automation github-project-automation bot moved this from Sprint: In Review to Sprint: Done in Semantic Kernel Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples 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

Successfully merging a pull request may close this issue.

2 participants