Skip to content

Commit

Permalink
.Net: Filters graduation (microsoft#7004)
Browse files Browse the repository at this point in the history
### 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.
-->

Resolves: microsoft#5409

1. Removed experimental flags on `FunctionInvocationFilter` and
`PromptRenderFilter`.
2. Updated 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 😄
  • Loading branch information
dmytrostruk authored Jul 8, 2024
1 parent 2a3ba0c commit 23f2dce
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ is an SDK that integrates Large Language Models (LLMs) like
[Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-services/openai-service),
and [Hugging Face](https://huggingface.co/)
with conventional programming languages like C#, Python, and Java. Semantic Kernel achieves this
by allowing you to define [plugins](https://learn.microsoft.com/en-us/semantic-kernel/ai-orchestration/plugins)
by allowing you to define [plugins](https://learn.microsoft.com/en-us/semantic-kernel/concepts/plugins)
that can be chained together
in just a [few lines of code](https://learn.microsoft.com/en-us/semantic-kernel/ai-orchestration/chaining-functions?tabs=Csharp#using-the-runasync-method-to-simplify-your-code).

Expand Down
92 changes: 46 additions & 46 deletions dotnet/docs/EXPERIMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,57 @@ You can use the following diagnostic IDs to ignore warnings or errors for a part

## Experimental Features Tracking

| SKEXP​ | Features​​ | API docs​​ | Learn docs​​ | Samples​​ | Issues​​ | Implementations​ |
|-------|----------|----------|------------|---------|--------|-----------------|
| SKEXP0001 | Embedding services | | | | | |
| SKEXP0001 | Image services | | | | | |
| SKEXP0001 | Memory connectors | | | | | |
| SKEXP0001 | Kernel filters | | | | | |
| SKEXP0001 | Audio services | | | | | |
| SKEXP​ | Features​​ |
|-------|----------|
| SKEXP0001 | Embedding services |
| SKEXP0001 | Image services |
| SKEXP0001 | Memory connectors |
| SKEXP0001 | Kernel filters |
| SKEXP0001 | Audio services |
| | | | | | | |
| SKEXP0010 | Azure OpenAI with your data service | | | | | |
| SKEXP0010 | OpenAI embedding service | | | | | |
| SKEXP0010 | OpenAI image service | | | | | |
| SKEXP0010 | OpenAI parameters | | | | | |
| SKEXP0010 | OpenAI chat history extension | | | | | |
| SKEXP0010 | OpenAI file service | | | | | |
| SKEXP0010 | Azure OpenAI with your data service |
| SKEXP0010 | OpenAI embedding service |
| SKEXP0010 | OpenAI image service |
| SKEXP0010 | OpenAI parameters |
| SKEXP0010 | OpenAI chat history extension |
| SKEXP0010 | OpenAI file service |
| | | | | | | |
| SKEXP0020 | Azure AI Search memory connector | | | | | |
| SKEXP0020 | Chroma memory connector | | | | | |
| SKEXP0020 | DuckDB memory connector | | | | | |
| SKEXP0020 | Kusto memory connector | | | | | |
| SKEXP0020 | Milvus memory connector | | | | | |
| SKEXP0020 | Qdrant memory connector | | | | | |
| SKEXP0020 | Redis memory connector | | | | | |
| SKEXP0020 | Sqlite memory connector | | | | | |
| SKEXP0020 | Weaviate memory connector | | | | | |
| SKEXP0020 | MongoDB memory connector | | | | | |
| SKEXP0020 | Pinecone memory connector | | | | | |
| SKEXP0020 | Postgres memory connector | | | | | |
| SKEXP0020 | Azure AI Search memory connector |
| SKEXP0020 | Chroma memory connector |
| SKEXP0020 | DuckDB memory connector |
| SKEXP0020 | Kusto memory connector |
| SKEXP0020 | Milvus memory connector |
| SKEXP0020 | Qdrant memory connector |
| SKEXP0020 | Redis memory connector |
| SKEXP0020 | Sqlite memory connector |
| SKEXP0020 | Weaviate memory connector |
| SKEXP0020 | MongoDB memory connector |
| SKEXP0020 | Pinecone memory connector |
| SKEXP0020 | Postgres memory connector |
| | | | | | | |
| SKEXP0040 | GRPC functions | | | | | |
| SKEXP0040 | Markdown functions | | | | | |
| SKEXP0040 | OpenAPI functions | | | | | |
| SKEXP0040 | OpenAPI function extensions | | | | | |
| SKEXP0040 | Prompty Format support | | | | | |
| SKEXP0040 | GRPC functions |
| SKEXP0040 | Markdown functions |
| SKEXP0040 | OpenAPI functions |
| SKEXP0040 | OpenAPI function extensions |
| SKEXP0040 | Prompty Format support |
| | | | | | | |
| SKEXP0050 | Core plugins | | | | | |
| SKEXP0050 | Document plugins | | | | | |
| SKEXP0050 | Memory plugins | | | | | |
| SKEXP0050 | Microsoft 365 plugins | | | | | |
| SKEXP0050 | Web plugins | | | | | |
| SKEXP0050 | Text chunker plugin | | | | | |
| SKEXP0050 | Core plugins |
| SKEXP0050 | Document plugins |
| SKEXP0050 | Memory plugins |
| SKEXP0050 | Microsoft 365 plugins |
| SKEXP0050 | Web plugins |
| SKEXP0050 | Text chunker plugin |
| | | | | | | |
| SKEXP0060 | Handlebars planner | | | | | |
| SKEXP0060 | OpenAI Stepwise planner | | | | | |
| SKEXP0060 | Handlebars planner |
| SKEXP0060 | OpenAI Stepwise planner |
| | | | | | | |
| SKEXP0070 | Ollama AI connector | | | | | |
| SKEXP0070 | Gemini AI connector | | | | | |
| SKEXP0070 | Mistral AI connector | | | | | |
| SKEXP0070 | ONNX AI connector | | | | | |
| SKEXP0070 | Hugging Face AI connector | | | | | |
| SKEXP0070 | Ollama AI connector |
| SKEXP0070 | Gemini AI connector |
| SKEXP0070 | Mistral AI connector |
| SKEXP0070 | ONNX AI connector |
| SKEXP0070 | Hugging Face AI connector |
| | | | | | | |
| SKEXP0101 | Experiment with Assistants | | | | | |
| SKEXP0101 | Experiment with Flow Orchestration | | | | | |
| SKEXP0101 | Experiment with Assistants |
| SKEXP0101 | Experiment with Flow Orchestration |
| | | | | | | |
| SKEXP0110 | Agent Framework | | | | | |
| SKEXP0110 | Agent Framework |
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Optimization;
/// This example shows how to use FrugalGPT techniques to reduce cost and improve LLM-related task performance.
/// More information here: https://arxiv.org/abs/2305.05176.
/// </summary>
public sealed class FrugalGPT(ITestOutputHelper output) : BaseTest(output)
public sealed class FrugalGPTWithFilters(ITestOutputHelper output) : BaseTest(output)
{
/// <summary>
/// One of the FrugalGPT techniques is to reduce prompt size when using few-shot prompts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Optimization;
/// It also helps to handle the scenario with a general purpose chat experience for a large enterprise,
/// where there are so many plugins, that it's impossible to share all of them with AI model in a single request.
/// </summary>
public sealed class PluginSelection(ITestOutputHelper output) : BaseTest(output)
public sealed class PluginSelectionWithFilters(ITestOutputHelper output) : BaseTest(output)
{
/// <summary>
/// This method shows how to select best functions to share with AI using vector similarity search.
Expand All @@ -37,7 +37,7 @@ public async Task UsingVectorSearchWithKernelAsync()
.AddOpenAITextEmbeddingGeneration("text-embedding-3-small", TestConfiguration.OpenAI.ApiKey);

// Add logging.
var logger = this.LoggerFactory.CreateLogger<PluginSelection>();
var logger = this.LoggerFactory.CreateLogger<PluginSelectionWithFilters>();
builder.Services.AddSingleton<ILogger>(logger);

// Add memory store to keep functions and search for the most relevant ones for specific request.
Expand Down Expand Up @@ -111,7 +111,7 @@ public async Task UsingVectorSearchWithChatCompletionAsync()
.AddOpenAITextEmbeddingGeneration("text-embedding-3-small", TestConfiguration.OpenAI.ApiKey);

// Add logging.
var logger = this.LoggerFactory.CreateLogger<PluginSelection>();
var logger = this.LoggerFactory.CreateLogger<PluginSelectionWithFilters>();
builder.Services.AddSingleton<ILogger>(logger);

// Add memory store to keep functions and search for the most relevant ones for specific request.
Expand Down
4 changes: 2 additions & 2 deletions dotnet/samples/Concepts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ Down below you can find the code snippets that demonstrate the usage of many Sem

## Optimization - Examples of different cost and performance optimization techniques

- [FrugalGPT](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Optimization/FrugalGPT.cs)
- [PluginSelection](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Optimization/PluginSelection.cs)
- [FrugalGPTWithFilters](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Optimization/FrugalGPTWithFilters.cs)
- [PluginSelectionWithFilters](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Optimization/PluginSelectionWithFilters.cs)

## Planners - Examples on using `Planners`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Diagnostics.CodeAnalysis;
using System.Threading;

namespace Microsoft.SemanticKernel;

/// <summary>
/// Class with data related to function invocation.
/// </summary>
[Experimental("SKEXP0001")]
public class FunctionInvocationContext
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;

namespace Microsoft.SemanticKernel;
Expand All @@ -11,7 +10,6 @@ namespace Microsoft.SemanticKernel;
/// <summary>
/// Interface for filtering actions during function invocation.
/// </summary>
[Experimental("SKEXP0001")]
public interface IFunctionInvocationFilter
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;

namespace Microsoft.SemanticKernel;
Expand All @@ -11,7 +10,6 @@ namespace Microsoft.SemanticKernel;
/// <summary>
/// Interface for filtering actions during prompt rendering.
/// </summary>
[Experimental("SKEXP0001")]
public interface IPromptRenderFilter
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Diagnostics.CodeAnalysis;
using System.Threading;

namespace Microsoft.SemanticKernel;

/// <summary>
/// Class with data related to prompt rendering.
/// </summary>
[Experimental("SKEXP0001")]
public sealed class PromptRenderContext
{
private string? _renderedPrompt;
Expand Down
4 changes: 0 additions & 4 deletions dotnet/src/SemanticKernel.Abstractions/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public Kernel Clone() =>
/// <summary>
/// Gets the collection of function filters available through the kernel.
/// </summary>
[Experimental("SKEXP0001")]
public IList<IFunctionInvocationFilter> FunctionInvocationFilters =>
this._functionInvocationFilters ??
Interlocked.CompareExchange(ref this._functionInvocationFilters, [], null) ??
Expand All @@ -141,7 +140,6 @@ public Kernel Clone() =>
/// <summary>
/// Gets the collection of function filters available through the kernel.
/// </summary>
[Experimental("SKEXP0001")]
public IList<IPromptRenderFilter> PromptRenderFilters =>
this._promptRenderFilters ??
Interlocked.CompareExchange(ref this._promptRenderFilters, [], null) ??
Expand Down Expand Up @@ -309,7 +307,6 @@ private void AddFilters()
}
}

[Experimental("SKEXP0001")]
internal async Task<FunctionInvocationContext> OnFunctionInvocationAsync(
KernelFunction function,
KernelArguments arguments,
Expand Down Expand Up @@ -351,7 +348,6 @@ await functionFilters[index].OnFunctionInvocationAsync(context,
}
}

[Experimental("SKEXP0001")]
internal async Task<PromptRenderContext> OnPromptRenderAsync(
KernelFunction function,
KernelArguments arguments,
Expand Down

0 comments on commit 23f2dce

Please sign in to comment.