Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: Fix KernelArgument bug in invoke_prompt functions (#8414)
### 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. --> In `invoke_prompt(...)` and `invoke_prompt_async(...)`, the `arguments` parameter is tested to see if it's empty before proceeding. The type of the `arguments` parameter is `KernelArgument`, which derives from a `dict` type, with an additional field for execution settings. When `arguments` contains only the execution settings, it will be considered as an empty dictionary. This will result in the `arguments` parameter being overridden completely, invalidating all execution settings passed to the APIs. To reproduce (assuming we have a plugin/function that will return the weather): ``` result = await kernel.invoke_prompt( "What is the weather like in my location?", arguments=KernelArguments( settings={ service_id: PromptExecutionSettings( service_id=service_id, function_choice_behavior=FunctionChoiceBehavior.Auto(), ), } ), ) ``` In the example above, the settings will be overridden to None. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Fix the bug. 2. Fix mypy in the pre-commit hook in order to commit. ### 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 - [x] I didn't break anyone 😄
- Loading branch information