-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: Introduce IAIServiceSelector interface to allow AI service and …
…request settings to be selected during semantic function execution (#3227) ### Motivation and Context Fix following issues for Semantic functions: 1. Allow semantic functions to dynamically retrieve the AI service and request settings to be used when executing the function Previously semantic functions execution has the following limitations: 1. The AI service was set on the semantic function when it was created. This meant that an instance of a semantic function could not be used with multiple different Kernel instances. 1. The AI request settings were set on the semantic function when it was created. This meant that different request settings could not be selected when the function was executed. ### Description This PR add's a new abstraction called `IAIServiceSelector`. An instance of this is added to a semantic function when it is created. The default implementation works as follows: 1. If the semantic function only has a single associated model request setting instance with no service id then the default AI service and the model request settings are used. This is consistent with the previous behaviour. 1. If the semantic function only has a single associated model request setting instance with a service id then the named AI service and the model request settings are used. If the named AI service is not available an exception will be thrown. This is consistent with the previous behaviour. 1. If the semantic function only has multiple associated model request setting instances then: 1. The model request setting instances are considered in order 1. The first model request setting instance with no service id is considered the default 1. For each model request setting instance that has a service id, if the service exists then it will be used with the associated model request settings 1. If no matching service can be found and default request settings are provided the default service will be used 1. If no matching service can be found and no default request settings are provided an exception will be thrown ### Contribution Checklist - [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
1 parent
aef2bdd
commit 3601022
Showing
30 changed files
with
814 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.