-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: Kernel service revamp and AIServiceSelector #5050
Python: Kernel service revamp and AIServiceSelector #5050
Conversation
@@ -92,8 +91,8 @@ class KernelFunction(KernelBaseModel): | |||
return_parameter: Optional[KernelParameterMetadata] = None | |||
function: Callable[..., Any] = Field(...) | |||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this kernel.select_ai_service
call one time and already have the service
and request_settings
available for assignment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
956f5c1
into
microsoft:python_kernel_args_latest
### 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 😄
### 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 😄
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