mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context This PR contains main implementation part of #4662 and adds it into `Functions.OpenApi.Extensions` project. There were also couple of bug fixes in the mentioned PR, those will be handled in subsequent PRs. API Manifest can describe capabilities of an AI plugin for a chat-based system among other things. For a full description of API Manifest, see the [API Manifest Specification](https://darrelmiller.github.io/api-manifest/draft-miller-api-manifest.html). API Manifest refers to one or more OpenAPI documents as API dependencies and it selects a subset of operations from those documents to describe the capabilities of an AI plugin. ### Description Semantic Kernel has a way of creating plugins from OpenAPI operations, but it has a couple of limitations that can be addressed with API Manifest: 1. It can only create functions from OpenAPI operations that are described in a single OpenAPI document. 2. It cannot reference multiple OpenAPI documents in a single plugin. Not being able to slice OpenAPI operations is a major limitation, especially for large APIs such as Microsoft Graph, which has over 1000 operations. Today, we can create a Semantic Kernel plugin from an OpenAPI file and one OpenAPI file corresponds to one plugin. We don't have a way of selecting a subset of operations. ```mermaid graph TB subgraph OpenAPI1 operation11 operation12 operation13 end subgraph OpenAPI2 operation21 operation22 operation23 end subgraph OpenAPIPlugin1 function11 function12 function13 end subgraph OpenAPIPlugin2 function21 function22 function23 end operation11 -.- function11 operation12 -.- function12 operation13 -.- function13 operation21 -.- function21 operation22 -.- function22 operation23 -.- function23 style OpenAPIPlugin1 fill:blue,color:white style OpenAPIPlugin2 fill:blue,color:white ``` ### Proposed Solution After Semantic Kernel APIManifest support, we will have an APIManifest file, which will be used as a filter on OpenAPI files and it can reference more than one OpenAPI file. The filter can be used as a guide to select only certain operations to be converted into functions. Assume that we want to create a single plugin with `function11` from `OpenAPI1` and `function21` and `function22` from `OpenAPI2`. We want to preserve the one-to-one mapping between the APIManifest and the plugin, e.g. between `ApiManifestX` and `PluginX`: ```mermaid graph TB subgraph OpenAPI1 operation11 operation12 operation13 end subgraph OpenAPI2 operation21 operation22 operation23 end subgraph APIManifestX reference11 reference21 reference22 end subgraph PluginX function11 function21 function22 end reference11 -.- operation11 reference21 -.- operation21 reference22 -.- operation22 function11 -.- reference11 function21 -.- reference21 function22 -.- reference22 style APIManifestX fill:green,color:white style PluginX fill:blue,color:white ``` If we use existing OpenAPI to Plugin public methods after on-the-fly slicing, we can only achieve the following because there is an assumption that a single OpenAPI is converted into a single plugin, which breaks APIManifest to Plugin one-to-one mapping. A single `APIManifestX` file corresponds to two plugins, namely, `PluginX1` and `PluginX2`: ```mermaid graph TB subgraph OpenAPI1 operation11 operation12 operation13 end subgraph OpenAPI2 operation21 operation22 operation23 end subgraph APIManifestX reference11 reference21 reference22 end subgraph OpenAPI1_Sliced operation11_sliced[operation11] end subgraph OpenAPI2_Sliced operation21_sliced[operation21] operation22_sliced[operation22] end subgraph PluginX1 function11 end subgraph PluginX2 function21 function22 end reference11 -.- operation11 reference21 -.- operation21 reference22 -.- operation22 operation11 -.- operation11_sliced -.- function11 operation21 -.- operation21_sliced -.- function21 operation22 -.- operation22_sliced -.- function22 style APIManifestX fill:green,color:white style PluginX1 fill:blue,color:white style PluginX2 fill:blue,color:white ``` To avoid this, the implementation of regular OpenAPI plugin generation and API Manifest plugin generation meets at the function generation level, so reuse starts at `CreateRestApiFunction`. The PR also adds a KernelSyntaxExample for `/me/messages` endpoint of Microsoft Graph. ### 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 😄 --------- Co-authored-by: SergeyMenshykh <[email protected]>
95 lines
6.3 KiB
XML
95 lines
6.3 KiB
XML
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
<PropertyGroup>
|
|
<UserSecretsId>5ee045b0-aea3-4f08-8d31-32d1a6f8fed0</UserSecretsId>
|
|
</PropertyGroup>
|
|
<PropertyGroup>
|
|
<AssemblyName>KernelSyntaxExamples</AssemblyName>
|
|
<RootNamespace></RootNamespace>
|
|
<TargetFramework>net6.0</TargetFramework>
|
|
<RollForward>LatestMajor</RollForward>
|
|
<IsTestProject>true</IsTestProject>
|
|
<IsPackable>false</IsPackable>
|
|
<!-- Suppress: "Declare types in namespaces", "Require ConfigureAwait", "Experimental" -->
|
|
<NoWarn>CS8618,IDE0009,CA1051,CA1050,CA1707,CA2007,VSTHRD111,CS1591,RCS1110,CA5394,SKEXP0001,SKEXP0002,SKEXP0003,SKEXP0004,SKEXP0005,SKEXP0010,SKEXP0011,,SKEXP0012,SKEXP0015,SKEXP0020,SKEXP0021,SKEXP0022,SKEXP0023,SKEXP0024,SKEXP0025,SKEXP0026,SKEXP0027,SKEXP0028,SKEXP0029,SKEXP0030,SKEXP0031,SKEXP0032,SKEXP0040,SKEXP0041,SKEXP0042,SKEXP0050,SKEXP0051,SKEXP0052,SKEXP0053,SKEXP0054,SKEXP0055,SKEXP0060,SKEXP0061,SKEXP0101,SKEXP0102</NoWarn>
|
|
<OutputType>Library</OutputType>
|
|
</PropertyGroup>
|
|
<ItemGroup>
|
|
<Compile Remove="RepoUtils\PlanExtensions.cs" />
|
|
</ItemGroup>
|
|
<ItemGroup>
|
|
<None Remove="Resources\GenerateStory.yaml" />
|
|
<None Remove="Resources\GenerateStoryHandlebars.yaml" />
|
|
<None Remove="Resources\travelinfo.txt" />
|
|
</ItemGroup>
|
|
<ItemGroup>
|
|
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
|
<PackageReference Include="xRetry" />
|
|
<PackageReference Include="xunit" />
|
|
<PackageReference Include="xunit.runner.visualstudio">
|
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
<PrivateAssets>all</PrivateAssets>
|
|
</PackageReference>
|
|
<PackageReference Include="Azure.Identity" />
|
|
<PackageReference Include="Microsoft.Extensions.Configuration" />
|
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
|
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
|
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
|
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
|
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
|
|
<PackageReference Include="Microsoft.Extensions.Http" />
|
|
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
|
|
<PackageReference Include="Microsoft.Extensions.Logging" />
|
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
|
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
|
|
<PackageReference Include="SharpToken" />
|
|
<PackageReference Include="Microsoft.ML.Tokenizers" />
|
|
<PackageReference Include="Microsoft.DeepDev.TokenizerLib" />
|
|
<PackageReference Include="System.Linq.Async" />
|
|
<PackageReference Include="System.Numerics.Tensors" />
|
|
</ItemGroup>
|
|
<ItemGroup>
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.OpenAI\Connectors.OpenAI.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.HuggingFace\Connectors.HuggingFace.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.AzureAISearch\Connectors.Memory.AzureAISearch.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Chroma\Connectors.Memory.Chroma.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Kusto\Connectors.Memory.Kusto.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.DuckDB\Connectors.Memory.DuckDB.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.MongoDB\Connectors.Memory.MongoDB.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Postgres\Connectors.Memory.Postgres.csproj" />
|
|
<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.Memory.Redis\Connectors.Memory.Redis.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Pinecone\Connectors.Memory.Pinecone.csproj" />
|
|
<ProjectReference Include="..\..\src\Experimental\Agents\Experimental.Agents.csproj" />
|
|
<ProjectReference Include="..\..\src\Experimental\Orchestration.Flow\Experimental.Orchestration.Flow.csproj" />
|
|
<ProjectReference Include="..\..\src\Extensions\PromptTemplates.Handlebars\PromptTemplates.Handlebars.csproj" />
|
|
<ProjectReference Include="..\..\src\Planners\Planners.Handlebars\Planners.Handlebars.csproj" />
|
|
<ProjectReference Include="..\..\src\Planners\Planners.OpenAI\Planners.OpenAI.csproj" />
|
|
<ProjectReference Include="..\..\src\SemanticKernel.Abstractions\SemanticKernel.Abstractions.csproj" />
|
|
<ProjectReference Include="..\..\src\Plugins\Plugins.Core\Plugins.Core.csproj" />
|
|
<ProjectReference Include="..\..\src\Plugins\Plugins.Memory\Plugins.Memory.csproj" />
|
|
<ProjectReference Include="..\..\src\Plugins\Plugins.MsGraph\Plugins.MsGraph.csproj" />
|
|
<ProjectReference Include="..\..\src\Functions\Functions.OpenApi\Functions.OpenApi.csproj" />
|
|
<ProjectReference Include="..\..\src\Functions\Functions.OpenApi.Extensions\Functions.OpenApi.Extensions.csproj" />
|
|
<ProjectReference Include="..\..\src\Functions\Functions.Grpc\Functions.Grpc.csproj" />
|
|
<ProjectReference Include="..\..\src\Connectors\Connectors.Memory.Qdrant\Connectors.Memory.Qdrant.csproj" />
|
|
<ProjectReference Include="..\..\src\Plugins\Plugins.Web\Plugins.Web.csproj" />
|
|
<ProjectReference Include="..\..\src\SemanticKernel.Core\SemanticKernel.Core.csproj" />
|
|
<PackageReference Include="System.Text.Json" />
|
|
</ItemGroup>
|
|
<ItemGroup>
|
|
<!-- Use newest available compiler to handle newer source-generating libraries used in the examples. -->
|
|
<!-- This can be removed once we no longer target the .NET 6 SDK in CI. -->
|
|
<PackageReference Include="Microsoft.Net.Compilers.Toolset" />
|
|
</ItemGroup>
|
|
<ItemGroup>
|
|
<EmbeddedResource Include="Resources\*">
|
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
</EmbeddedResource>
|
|
</ItemGroup>
|
|
<ItemGroup>
|
|
<None Include="Plugins\ApiManifestPlugins\**\apimanifest.json">
|
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
</None>
|
|
</ItemGroup>
|
|
</Project> |