semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: Enable the possibility to select another service using `IPromptRenderFilter`.

Open rogerbarreto opened this issue 1 year ago • 2 comments

Describe the bug

The current PromptRenderFiltering happens after the service was selected in the Kernel, even changing the context.Arguments.ExecutionSettings.First().Value.ServiceId won't be effective.

Expected behavior Since prompt rendering happens before calling the connector, seems to be an error not be able to override that configuration and select a new connector serviceId from the filter context settings.

rogerbarreto avatar Aug 02 '24 13:08 rogerbarreto

This is a new feature and not a bug, adding to the backlog so we can prioritise this.

markwallace-microsoft avatar Aug 02 '24 13:08 markwallace-microsoft

In my opinion, we should clearly define the responsibility of each filter. IPromptRenderFilter is related to prompt rendering operation only, I'm not sure it should have an ability to pick AI service. If it's important to select another service in the middle of the execution, it's possible to use IFunctionInvocationFilter, we have an example how to do it: https://github.com/microsoft/semantic-kernel/blob/a53b96a1ae066160872b3cad65387442995a788d/dotnet/samples/Concepts/Filtering/RetryWithFilters.cs#L49-L70

There is a clear use-case for IFunctionInvocationFilter, when function invocation fails and user wants to try the same function with different model. I'm wondering, what could possibly happen during prompt rendering operation that it will be necessary to change AI service inside IPromptRenderFilter. If there is some use-case, it would be great to discuss it further.

dmytrostruk avatar Aug 02 '24 19:08 dmytrostruk