-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeai connectorAnything related to AI connectorsAnything related to AI connectorsbugSomething isn't workingSomething isn't workingcore pluginAnything related to core pluginsAnything related to core pluginsfunction_callingmsft.ext.aiRelated to Microsoft.Extensions.AIRelated to Microsoft.Extensions.AIsamples
Description
Describe the bug
AI services based on IChatClient
does not invoke filters.
To Reproduce
Steps to reproduce the behavior:
IChatClient chatClient = ...; // However one creates a chat client
IKernelBuilder builder = Kernel.CreateBuilder();
builder.Services.AddSingleton(functionCallingChatClient);
Kernel kernel = builder.Build();
kernel.Plugins.AddFromType<MyPlugin>(); // Any plugin
kernel.FunctionInvocationFilters.Add(new MyFunctionFilter());
kernel.InvokePromptAsync(
"<some message that triggers function invocation>",
new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() });
private sealed class MyFunctionFilter : IFunctionInvocationFilter
{
public async Task OnFunctionInvocationAsync(FunctionInvocationContext context, Func<FunctionInvocationContext, Task> next)
{
System.Console.WriteLine($"INVOKING: {context.Function.Name}");
await next.Invoke(context);
System.Console.WriteLine($"RESULT: {context.Result}");
}
}
Expected behavior
Filter invoked as part of function invocation.
Platform
- Language: C#
- Source:
main
Additional context
Transition to support MEAI IChatClient
should be seamless. Instead, there is a silent failure for an existing application or service that is using filters. This is not at parity for SK developers and has poor discoverability (unable to realize what doesn't work ahead of time).
NOTE: Certain of our AI connectors primarily rely on
IChatClient
(i.e. Ollama).
tommasodotNET
Metadata
Metadata
Assignees
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeai connectorAnything related to AI connectorsAnything related to AI connectorsbugSomething isn't workingSomething isn't workingcore pluginAnything related to core pluginsAnything related to core pluginsfunction_callingmsft.ext.aiRelated to Microsoft.Extensions.AIRelated to Microsoft.Extensions.AIsamples
Type
Projects
Status
Sprint: Done