-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
.Net: Feat: adds support for Microsoft Manifest in dotnet and other fixes. #9436
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
fix: loading of location OAS descriptions for Microsoft manifests Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
…t manifests Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
Signed-off-by: Vincent Biret <[email protected]>
} | ||
}, | ||
"Astronomy": { | ||
"apiDescriptionUrl": "https://raw.githubusercontent.com/zengin/openapi-directory/zengin/nasa/APIs/nasa.gov/apod/1.0.0/openapi.yaml", |
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.
I think we should not take a dependency on my account here. Is there any chance this file can be moved to a Microsoft owned location? I think I needed a copy for adding auth details.
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.
Sure, we can point it somewhere else. Do you remember where you took it from?
@@ -0,0 +1,79 @@ | |||
{ | |||
"applicationName": "application", |
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.
Consider moving all the documents from the .kiota
folder closer to the code that uses them. If those are required for plugin generation, please move them to the plugins folder and add a README describing how to generate those plugins from the documents.
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Sqlite\Connectors.Memory.Sqlite.csproj" /> | ||
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Weaviate\Connectors.Memory.Weaviate.csproj" /> | ||
<ProjectReference | ||
Include="..\..\src\Connectors\Connectors.HuggingFace\Connectors.HuggingFace.csproj" /> |
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.
Please review the changes in this file and others, and roll back any unnecessary ones, such as those related to formatting that move the Include
attribute to a new line.
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" | ||
Version="8.0.0" /> |
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.
Revert unnecessary changes.
#endregion | ||
]; | ||
[Theory, MemberData(nameof(s_parameters))] | ||
public async Task RunSampleWithPlannerAsync(string pluginToTest, string functionToTest, KernelArguments? arguments, params string[] pluginsToLoad) |
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.
This sample, like the ApiManifest one, doesn’t use Planner as far as I can tell. I suggest renaming them to avoid the Planner
keyword, like RunMicrosoftManifestPlugin
and RunApiManifestPlugin
.
["ContactsPlugin", "me_ListContacts", new KernelArguments() { { "_count", "true" } }, "ContactsPlugin", "MessagesPlugin"], | ||
["CalendarPlugin", "me_calendar_ListEvents", new KernelArguments() { { "_top", "1" } }, "CalendarPlugin", "MessagesPlugin"], | ||
|
||
#region Multiple API dependencies (multiple auth requirements) scenario within the same plugin |
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.
Is the region really needed here? Won't an XML comment suffice?
var response = await LoadDocumentResponseFromUriAsync(uri, logger, httpClient, authCallback, userAgent, cancellationToken).ConfigureAwait(false); | ||
return await response.Content.ReadAsStreamAndTranslateExceptionAsync().ConfigureAwait(false); |
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.
The response is not disposed here; consider wrapping the response and the stream into HttpResponseStream
the same way it's done in the RestApiOperationRunner.
@@ -58,10 +77,34 @@ internal static async Task<string> LoadDocumentFromFilePathAsync( | |||
#endif | |||
).ConfigureAwait(false); | |||
} | |||
private static void CheckIfFileExists(string filePath) |
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.
Please add new line between the methods and move the private to the bottom to keep internal methods as a group above.
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.
I would also consider moving these kernel extensions and the MicrosoftManifestKernelExtensions
ones to the Microsoft.SemanticKernel
namespace so that they can be easily discovered by consumers on kernel when the extension package is installed.
/// <summary> | ||
/// API manifest plugin parameters. | ||
/// </summary> | ||
public class MicrosoftManifestPluginParameters |
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.
The XML comment is not relevant to the class + consider sealing class.
/// <param name="httpClient">Http client to be used in plugin initialization phase.</param> | ||
/// <param name="userAgent">User agent to be used in plugin initialization phase.</param> | ||
/// <param name="functionExecutionParameters">A map of function execution parameters.</param> | ||
public MicrosoftManifestPluginParameters( |
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.
Working on SK for a long period of time, we've noticed that the number of constructor parameters for the parameter/metadata/options classes tends to grow over time, and it is quite difficult to add new ones and keep existing in logical order without introducing breaking changes. So, my advice would be to remove the constructor and use props only. Adding a new property would be just one line without the necessity of changing the constructor and worrying about potential breaking changes.
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.
Does MicrosoftManifest supersede the ApiManifest? If that is the case, should the ApiManifest functionality be obsoleted or removed?
Motivation and Context
.
by_
so function names are valid.Description
Contribution Checklist
On the unit tests: I'd like guidance on where to add unit tests for:
Why so many files?
./kiota
: all generated files, it contains kiota workspace configuration, which comes with copies of the OAS descriptions, etc… You don’t need to review it manually. It is useful because it allows us to automatically generate/refresh the integration tests plugins. If you feel like it's adding too much noise, we can remove those, we'll loose the ability to refresh the plugins definitions. https://aka.ms/kiotaSamples/concepts
: restored the api manifest for astronomy API to fix the API manifest integration test. Added sample Microsoft Manifest for the new integration tests. Those are automatically generated via kiota and can be automatically refreshed later.Src/Functions
: Microsoft manifests implementation, API manifest fixes.How to run the local tests
Create the following JSON file
D:\github\semantic-kernel\dotnet\samples\Concepts\bin\Debug\net8.0\appsettings.Development.json
(for some reason given how the project is setup this file is not being copied automatically. I didn't to touch any of the project setup out of fear of breaking other things)Replace the clientId and TenantId by your own value.
To create the application registration, go to https://aad.portal.azure.com, create a new application registration, new public client (add the redirect URI). In API access, add the listed Microsoft Graph delegated scopes. Grant consent after adding the scopes. During the first run, your browser will open to get the token.
File paths and copies
Like for the development settings, the project is NOT copying the sample plugin files for some reason. This is why the loading of the files in the integration tests looks at source files directly with
../../../
path segments. Happy to review that upon guidance.License for Astrology plugins
The description is under the Apache license. I added the plugin (API and Microsoft) to restore the integration test for the former and mirror the setup to the latter. In the case of API plugins, we're only referring to it, so having a plugin is fine. In case of the Microsoft plugin, we have a full copy under the kiota configuration directory, and a sliced down version (derived work) in the example plugin. The value of this API is that it allows us to test scenarios outside of Microsoft Graph. But if the license is a challenge, we can remove those before merging. @RogerBarreto to provide more context on why those were deleted at the first place in #6005
Why so many commits?
Incremental work during the implementation, plus regular merges from main to make sure everything was current and we wouldn't end up with conflicts, etc... Happy to rebase and squash once the initial reviews are through.