Python: Kernel service revamp and AIServiceSelector#5050
Merged
moonbox3 merged 3 commits intomicrosoft:python_kernel_args_latestfrom Feb 16, 2024
Merged
Conversation
moonbox3
reviewed
Feb 16, 2024
| plugins: Optional["KernelPluginCollection"] = Field(default=None) | ||
| ai_service: Optional[Union[TextCompletionClientBase, ChatCompletionClientBase]] = Field(default=None) | ||
| prompt_execution_settings: PromptExecutionSettings = Field(default_factory=PromptExecutionSettings) | ||
| # ai_service: Optional[Union[TextCompletionClientBase, ChatCompletionClientBase]] = Field(default=None) |
| if param.name == "client": | ||
| function_arguments[param.name] = self.ai_service | ||
| if param.name == "service": | ||
| function_arguments[param.name] = kernel.select_ai_service(self, arguments)[0] |
Collaborator
There was a problem hiding this comment.
Can we do this kernel.select_ai_service call one time and already have the service and request_settings available for assignment?
Member
Author
There was a problem hiding this comment.
Moved it here because some functions don't use it, guess there is a different way to do it but this worked and the function isn't heavy, but I guess someone can override with something more complex... I'll have a look.
moonbox3
approved these changes
Feb 16, 2024
juliomenendez
approved these changes
Feb 16, 2024
eavanvalkenburg
added a commit
that referenced
this pull request
Feb 20, 2024
### 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. --> Implements the AI Service Selector mechanism Revamps and simplifies the services in the Kernel Made service_id required field on all services ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> - Removed the individual service fields in kernel, replaced with single one, with dict[str, Class] as type - Also removed default_service fields from kernel - Reordered methods in Kernel and added region notes for easier folding in IDE - Added new service management methods incl tests, removed old ones. - Removed service linking to default service from kernel_function - Added AIServiceSelector class, single method that can be overridden, returns service and execution_settings with the right type - Removed usage of chat_prompt related fields, now checks if service is ChatCompletion and then usage that, otherwise falls back to TextCompletion - Added kernel test folder, with kernel_service_management tests, completely covering service related functions ### 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 - [ ] I didn't break anyone 😄
eavanvalkenburg
added a commit
that referenced
this pull request
Feb 22, 2024
### 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. --> Implements the AI Service Selector mechanism Revamps and simplifies the services in the Kernel Made service_id required field on all services ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> - Removed the individual service fields in kernel, replaced with single one, with dict[str, Class] as type - Also removed default_service fields from kernel - Reordered methods in Kernel and added region notes for easier folding in IDE - Added new service management methods incl tests, removed old ones. - Removed service linking to default service from kernel_function - Added AIServiceSelector class, single method that can be overridden, returns service and execution_settings with the right type - Removed usage of chat_prompt related fields, now checks if service is ChatCompletion and then usage that, otherwise falls back to TextCompletion - Added kernel test folder, with kernel_service_management tests, completely covering service related functions ### 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 - [ ] I didn't break anyone 😄
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Implements the AI Service Selector mechanism
Revamps and simplifies the services in the Kernel
Made service_id required field on all services
Description
Contribution Checklist