Replies: 1 comment 2 replies
-
Based on the current implementation of AddBedrockChatClient, it seems there is no direct way to inject custom middleware at this point. builder.Services.AddKeyedTransient<Kernel>("Kernel", (sp, _) =>
{
var kernelBuilder = Kernel.CreateBuilder();
kernelBuilder.Services.AddChatClient(sp =>
{
var bedrockRuntime = new AmazonBedrockRuntimeClient(credentials, clientConfig);
return bedrockRuntime.AsIChatClient();
})
.UseLogging()
.UseOpenTelemetry()
.UseKernelFunctionInvocation()
.UseYourMiddleware();
return kernelBuilder.Build();
}); The key point here is to use UseKernelFunctionInvocation to ensure that the middleware responsible for handling automatic plugin invocation in Semantic Kernel is properly configured. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to figure out how to add middleware to a chat client added to the Kernel. It seems like I need the actual instance of the chat client in order to add the middleware?
This is the documentation for the chat client middleware https://learn.microsoft.com/en-us/dotnet/ai/microsoft-extensions-ai#custom-ichatclient-middleware
This is my setup
This is the middleware:
And this is how I finally use the kernel
At what point should I/can I extend the Bedrock chat client?
Beta Was this translation helpful? Give feedback.
All reactions