-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add support for custom delegates as SKFunctions #893
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dluc
force-pushed
the
dluc148customdelegates
branch
from
May 9, 2023 21:59
fe0d8ba
to
7b9df03
Compare
github-actions
bot
added
.NET
Issue or Pull requests regarding .NET code
kernel
Issues or pull requests impacting the core kernel
kernel.core
labels
May 9, 2023
shawncal
reviewed
May 9, 2023
dluc
force-pushed
the
dluc148customdelegates
branch
from
May 9, 2023 22:15
7b9df03
to
59d9e81
Compare
dluc
added
PR: ready for review
All feedback addressed, ready for reviews
PR: ready to merge
PR has been approved by all reviewers, and is ready to merge.
labels
May 9, 2023
dluc
force-pushed
the
dluc148customdelegates
branch
from
May 10, 2023 01:57
ab1107a
to
dc47bec
Compare
The PR is ready to be merged. One of the issues fixed here has been addressed also in #900 so the remaining part is fixing how native function signatures are handled reusing the same code used for native skills. |
dluc
force-pushed
the
dluc148customdelegates
branch
from
May 10, 2023 02:35
a0d2eae
to
52dcf2c
Compare
dluc
force-pushed
the
dluc148customdelegates
branch
from
May 10, 2023 02:36
52dcf2c
to
4f938c4
Compare
lemillermicrosoft
approved these changes
May 10, 2023
adrianwyatt
approved these changes
May 10, 2023
adrianwyatt
removed
the
PR: ready for review
All feedback addressed, ready for reviews
label
May 10, 2023
dehoward
pushed a commit
to lemillermicrosoft/semantic-kernel
that referenced
this pull request
Jun 1, 2023
### Motivation and Context In some scenarios like RPC and OpenAPI it can be useful turning native code into SK Functions allowing to pass signature details (name, description, params) without the use of SK* attributes. For example, loading these details from OpenAPI docs or config files, rather than using reflection. ### Description Add a new `FromNativeFunction` factory method to `SKFunction` to pass a custom delegate. The custom delegate must use one of the supported signatures, but doesn't need the "SK*[...]" attributes. Example: ``` async Task<SKContext> MyFunctionAsync(SKContext context) { await Task.Delay(0); return context; } ``` ``` ISKFunction function = SKFunction.FromNativeFunction( nativeFunction: MyFunctionAsync, skillName: "Test", functionName: "HelloWorld" description: "This is a test"); ``` Co-authored-by: Adrian Bonar <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kernel
Issues or pull requests impacting the core kernel
.NET
Issue or Pull requests regarding .NET code
PR: ready to merge
PR has been approved by all reviewers, and is ready to merge.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
In some scenarios like RPC and OpenAPI it can be useful turning native code into SK Functions allowing to pass signature details (name, description, params) without the use of SK* attributes. For example, loading these details from OpenAPI docs or config files, rather than using reflection.
Description
Add a new
FromNativeFunction
factory method toSKFunction
to pass a custom delegate. The custom delegate must use one of the supported signatures, but doesn't need the "SK*[...]" attributes.Example: