Commit Graph
15 Commits
Author SHA1 Message Date
Roger Barreto da2dfda017 .Net Removing special "input" argument (#4156)
### Motivation and Context

Resolves #3887 

Before:
```csharp
var result = await kernel.InvokeAsync(excuseFunction, new("I missed the F1 final race"));
```

After:
```csharp
var result = await kernel.InvokeAsync(excuseFunction, new() { ["input"] = "I missed the F1 final race" });
```
2023-12-12 14:49:49 +00:00
aa45ee6b08 .Net: Address API review feedback about DI integration (#4023)
- Replaces WithServices/WithPlugins callback-based methods with
Services/Plugins properties. It makes it less fluent, but it brings it
into line with the current best-practices patterns used by ASP.NET, it
reduces nesting, it avoids confusion about when the callbacks are
invoked, it avoids async-related issues, and it makes the pre-Build
syntax for adding plugins to the builder much closer to the post-Build
syntax for adding plugins to the Kernel.
- Plugins added as services are now automatically resolved as part of
Kernel construction. The Kernel will prefer to use a collection it's
explicitly handed, but if it isn't given one, it'll try to fetch a
collection from the services, and if it can't find that, it'll try to
fetch all IKernelPlugins from the services.
- Renamed With methods to Add methods to improve parity both with
current ASP.NET practices as well as between when doing `builder.AddXx`
and `builder.Services.AddXx`.
- Renamed `AddPluginFromObject<T>` to `AddFromType<T>`.
- Remove `new()` constraint from `AddFromType<T>` and instead use
ActivatorUtilities.CreateInstance. The KernelBuilder.Plugins property
contains the same IServiceCollection as the builder, and so
`AddFromType<T>` has access to it and can use it with CreateInstance to
resolve any plugin object ctor arguments from the service provider. For
example, HttpPlugin has a ctor that takes an HttpClient, so now doing
`builder.Plugins.AddFromType<HttpPlugin>()` will find an HttpClient in
the container and use it automatically when the plugins are built as
part of Build.
- Removed WithLoggerFactory and WithCulture. The latter is basically
never used, and it's much more like the Data property and event handlers
on the Kernel, where it can easily be mutated on the Kernel instance and
doesn't need any builder support. WithLoggerFactory was used a lot, but
mainly because of the patterns employed in the tests, and it's easily
replacable with AddLogging.
- Added IKernelBuilder interface. It's implemented by KernelBuilder and
returned from a new AddKernel extension method on IServiceCollection,
adding a singleton KernelPluginCollection and a transient Kernel to the
container. IKernelBuilder has both the Services and Plugins properties,
and also has Build, but Build throws an exception if it's used on the
instance returned from AddKernel, per feedback that it can lead to folks
accidentally building the container multiple times.
- Changed all of the extensions on KernelBuilder to instead by on
IKernelBuilder.

@davidfowl, @halter73, please ensure this is in line with your feedback.
Thanks!

---------

Co-authored-by: Mark Wallace <[email protected]>
Co-authored-by: SergeyMenshykh <[email protected]>
2023-12-06 22:28:38 +00:00
Stephen Toub 3249099035 .Net: Remove string? input overloads and add KernelArgument ctor (#3985)
Fixes https://github.com/microsoft/semantic-kernel/issues/3884
2023-12-05 17:40:55 +00:00
Mark Wallace c636d8b691 .Net: Rename Kernel.RunAsync to Kernel.InvokeAsync (#3654)
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### 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 😄
2023-11-24 15:45:05 +00:00
Mark Wallace bc2d83c11e .Net: Remove support for passing multiple functions to Kernel.RunAsync (#3647)
### Motivation and Context

- `Kernel.RunAsync` will only support running a single function
- Plans can be use dto run multiple functions if needed or
- Developers can create their own strategy to do this

### Contribution Checklist

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

- [x] The code builds clean without any errors or warnings
- [x] 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
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
2023-11-23 20:34:44 +00:00
a0b3ad35ae .Net Kernel improvements for V1 (#3543)
### Motivation and Context
This PR introduces a few new improvements to make SK simpler, flexible
and developer friendly:
- Plugins support -
https://github.com/microsoft/semantic-kernel/pull/3474
- Kernel as a state/property bag -
https://github.com/microsoft/semantic-kernel/pull/3489,
https://github.com/microsoft/semantic-kernel/pull/3516
- SKFunction / SKPlugin factory methods -
https://github.com/microsoft/semantic-kernel/pull/3493
- Kernel is passed to SKFunction.InvokeAsync -
https://github.com/microsoft/semantic-kernel/pull/3531

---------

Co-authored-by: Stephen Toub <[email protected]>
Co-authored-by: Mark Wallace <[email protected]>
2023-11-20 18:33:32 +00:00
ba40209e24 .Net: Remove Kernel.Builder (#3180)
#3169 
Use `new KernelBuilder()` instead of `Kernel.Builder`

---------

Co-authored-by: Dmytro Struk <[email protected]>
Co-authored-by: Roger Barreto <[email protected]>
2023-10-24 11:01:28 +00:00
Dmytro Struk 3037500a66 .Net: Fixed examples and XML documentation (#3075)
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

This PR contains changes to fix SK syntax examples after
`KernelResult`/`FunctionResult` functionality was merged.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
1. Fixed result output in SK syntax examples.
2. Updated XML documentation.

### Contribution Checklist

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

- [x] The code builds clean without any errors or warnings
- [x] 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
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
2023-10-05 14:13:33 +00:00
Mark Wallace 3451a4ebbc .Net: Rename ImportXXXPlugins methods to ImportXXXFunctions (#2937)
### Motivation and Context

As part of the Skill -> Plugin rename the `ImportSkill` and
`ImportSemanticSkillFromDirectory` where renamed to use the term
`Plugin`. These methods actually import functions to the Kernel so this
PR renames them to match what they actually do.

We want to reserve `ImportPlugin` for use later when we add more plugin
support to the SK.

So now we do this:
`var functions = kernel.ImportFunctionsFromDirectory(...);`

In future we will do this
`var plugin = kernel.ImportPluginFromDirectory(...);`

The plugin instance will contain a list of functions in addition to
other data about the plugin.

### 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 😄
2023-09-23 19:42:14 +00:00
Mark WallaceandLee Miller e3868df257 .Net: Rename 'Skills' -> 'Plugins' - Part 5 (#2918)
### Motivation and Context

- Update samples to use plugins and not skills
- Update integration tests to use plugins and not skills
- Switch to using the sample semantic plugins

### Contribution Checklist

- [x] The code builds clean without any errors or warnings
- [x] 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
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

---------

Co-authored-by: Lee Miller <[email protected]>
2023-09-22 06:08:23 +00:00
Mark Wallace b3c5ee05d7 .Net: Rename 'Skills' -> 'Plugins' - Part 3 (#2904)
### Motivation and Context

Rename Skills to Functions for SK core and abstractions packages. Third
sub task from https://github.com/microsoft/semantic-kernel/issues/2119.

### Description

- Remove the `Microsoft.SemanticKernel.SkillDefinition` namespace and
promote classes previously contained to `Microsoft.SemanticKernel`, this
is to reduce the number of `using`s that client code required.
 - Rename variable/function names using skillName to pluginName.
- Rename skill collection interfaces/classes to use function collection.
- Leave some obsolete methods/properties to help with the upgrade from
earlier releases.

### Contribution Checklist

- [x] The code builds clean without any errors or warnings
- [x] 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
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
2023-09-21 13:08:21 +00:00
Mark Wallace c10f7c4e3a .Net: Rename 'Skills' -> 'Plugins' - Part 1 (#2854)
### Motivation and Context

Rename `Skills` to `Plugins`. First sub task from
https://github.com/microsoft/semantic-kernel/issues/2119.

### Description

This is the first PR

1. Move Core, Document, MsGraph and Web skill projects to a new
`Plugins` folder
2. Update Core, Document, MsGraph and Web projects to use `Plugins`
instead of `Skills` in assembly names, namespace, class names
3. Extract text from `Skills.UnitTests` and create new
`Plugins.UnitTests` project

Solution Explorer:

![image](https://github.com/microsoft/semantic-kernel/assets/127216156/16dd8146-d8a0-44e3-8995-894afb644e09)

File Explorer:

![image](https://github.com/microsoft/semantic-kernel/assets/127216156/1aef0bd9-ac54-492f-8725-eac0d3e6db86)

### Contribution Checklist

- [x] The code builds clean without any errors or warnings
- [x] 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
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
2023-09-18 18:58:36 +00:00
2e84b30e21 .Net: Change public APIs to accept ILoggerFactory (#2472)
### Motivation and Context

Following best practices for libraries outlined at
https://learn.microsoft.com/en-us/dotnet/core/extensions/logging-library-authors,
SK should generally be taking an ILoggerFactory rather than an ILogger.
This allows individual components to each get a logger with its own
category applied.

### Contribution Checklist

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

- [x] The code builds clean without any errors or warnings
- [x] 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
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄

---------

Co-authored-by: Shawn Callegari <[email protected]>
Co-authored-by: Lee Miller <[email protected]>
2023-08-21 23:39:58 +00:00
Shawn Callegari 6cee23fd5f .Net: Standardize name 'logger' across the project (#2186)
### Description
Throughout the repo, we have a mix of `logger` and `log` (plus
variations such as `Log`, `_log`) used to hold an `ILogger` instance.

This PR seeks to standardize the name `logger`, `Logger` and `_logger`
to represent ILogger object references -- including properties and
method parameters -- and `Log` as the method (action) that the logger
can take.

**To reviewers**, this is a large and extraordinarily mundane PR with
many identical substitutions. Please take a closer look at:
- IKernel.cs
- Kernel.cs
- SKContext.cs
...as these additionally contain Obsoleted properties.

### Contribution Checklist
- [X] The code builds clean without any errors or warnings
- [X] 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
- [X] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
     => This is a breaking change.
2023-07-26 16:58:13 +00:00
Shawn Callegariandname f8a8d884ff Moving KernelSyntaxExamples into the dotnet/ folder (#1616)
"KernelSyntaxExamples" is the only outstanding project under /samples
that still uses project references to access the kernel libraries.

This change consolidates all the building, linked dotnet SDK code in
SK-dotnet.sln into a single top-level folder. This will simplify build
jobs, automatic code owner assignment, and other dev ops tasks.

Coming next: other projects in samples will get removed from the
dotnet/SK-dotnet.sln solution, and a new solution with dedicated builds
created for the /samples folder.

TBD:
- Language-specific code "samples" will move into a similar subfolder
for each language.
- The current "/samples" folder (at the root) will likely become
something like "apps", with the demo apps promoted to the top-level
folder for better discoverability.
- notebooks may also move to this folder in the future.

Co-authored-by: name <email>
2023-06-21 01:37:54 +00:00