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
gRPC skills functionality #814
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
### Motivation and Context This PR adds a few building blocks for gRPC skills support. The rest of the functionality - gRPC skills import, support for complex data contract, retries, etc. will/might be added later. ### Description This PR add the following classes/components: - Skills.Grpc - project/package added to keep gRPC related functionality. - ProtoDocumentParser - class responsible for parsing .ptoto files and extract them into a list of operations represented by GrpcOperation class. - GrpcOperation - model class that describes a gRPC operation. - GrpcOperationRunner - class responsible for running a gRPC operation. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) - [x] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with `dotnet format` - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Shawn Callegari <36091529+shawncal@users.noreply.github.com>
### Motivation and Context This change adds functionality required for gRPC skills import to Kernel allowing SK SDK client code to register and use gRPC skills in SK SDK. ### Description This change adds a few ImportGrpc* Kernel extension methods that can import gRPC skills from a folder or a file. Additionality, GrpcOperationRunner is changed to accept gRPC request message as JSON and return the gRPC method result as JSON as well. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) - [x] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with `dotnet format` - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
…) with a sample proto file (#768) ### Motivation and Context This is related to #451, craigomatic#13, and craigomatic#16, where we want to demonstrate how Native skills can be invoked via gRPC and implemented across various languages. In this case, we are specifically implementing this polyglot Native skill in Java due to customer inquiries. ### Description This change introduces a sample Java application that functions as a gRPC server. The `GrpcOperationRunner` can invoke Java code using the [activity.proto file in this PR](https://github.com/thegovind/semantic-kernel/blob/feature-grpc/samples/java/JavaReferenceSkill/src/main/proto/activity.proto) and its operation `GetRandomActivity`, as shown in [`Example27_GrpcSkills` in `kernel-syntax-examples`](https://github.com/microsoft/semantic-kernel/pull/730/files#diff-29f0ad84e48c3fe28f2ad26603940927306a57aaf76f6c01fc19e7ac82e33da0).
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 4, 2023
SergeyMenshykh
added
PR: ready for review
All feedback addressed, ready for reviews
.NET
Issue or Pull requests regarding .NET code
and removed
.NET
Issue or Pull requests regarding .NET code
kernel
Issues or pull requests impacting the core kernel
samples
labels
May 4, 2023
…h with the main one. (#816) ### Motivation and Context Fix for the latest, partially successful, merge of gRPC feature branch with the main one.
github-actions
bot
added
kernel
Issues or pull requests impacting the core kernel
kernel.core
labels
May 4, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick pass
dotnet/src/SemanticKernel.Abstractions/SemanticKernel.Abstractions.csproj
Outdated
Show resolved
Hide resolved
dotnet/src/Skills/Skills.Grpc/Extensions/GrpcOperationExtensions.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Skills/Skills.Grpc/Extensions/KernelGrpcExtensions.cs
Outdated
Show resolved
Hide resolved
RogerBarreto
reviewed
May 5, 2023
### Description This PR addresses comments made in another PR to merge feature-grpc branch to the main one. It also contains a small improvement that prevents creation of HttpClient per each gRPC operation run and use only one HttpClient instance per set of skills imported together. Later, in scope of a different task, another improvement will be done to allow hosting apps to provide their instances of HttpClient, if needed.
lemillermicrosoft
approved these changes
May 8, 2023
shawncal
approved these changes
May 8, 2023
dluc
reviewed
May 9, 2023
@@ -38,8 +34,10 @@ | |||
<PackageVersion Include="Microsoft.Identity.Client.Extensions.Msal" Version="[2.28.0, )" /> | |||
<PackageVersion Include="Microsoft.OpenApi" Version="[1.6.3, )" /> | |||
<PackageVersion Include="Microsoft.OpenApi.Readers" Version="[1.6.3, )" /> | |||
<PackageVersion Include="Newtonsoft.Json" Version="[13.0.3, )" /> | |||
|
|||
<PackageVersion Include="Newtonsoft.Json" Version="[11.0.1, )" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dehoward
pushed a commit
to lemillermicrosoft/semantic-kernel
that referenced
this pull request
Jun 1, 2023
### Motivation and Context This PR adds MVP functionality for gRPC skills by introducing a set of classes for importing, parsing and executing gRPC operations defined in the .proto files. This functionality may be useful in scenarios when skills are represented as methods that are hosted on a different machine and need to be called remotely. ### Description The PR adds the following classes: - ProtoDocumentParser - iterates over a all methods of all services declared in .proto file and creates an instance of GrpcOperation model class for each of them. - GrpcOperation - model class representing gRPC operation. - GrpcOperationRunner - accepts an instance of the GrpcOperation class and a collection of arguments. Dynamically creates an instance of gRPC method request and calls the method. Receives, transforms and returns the method call result. - GrpcOperationExtensions - extension methods for GrpcOperation to extend the class with SK SDK domain related functionality. - KernelGrpcExtensions - declares a few register and import methods for importing the gRPC skills from a folder or a file and registering them in SK Kernel. Co-authored-by: Shawn Callegari <36091529+shawncal@users.noreply.github.com> Co-authored-by: Govind Kamtamneni <gok@microsoft.com>
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 for review
All feedback addressed, ready for reviews
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
This PR adds MVP functionality for gRPC skills by introducing a set of classes for importing, parsing and executing gRPC operations defined in the .proto files. This functionality may be useful in scenarios when skills are represented as methods that are hosted on a different machine and need to be called remotely.
Description
The PR adds the following classes:
Contribution Checklist
dotnet format