Skip to content

Commit 68448b1

Browse files
authored
Python: Fix kernel parameter metadata input type arg to call type_ (#10603)
### Motivation and Context To address a typing issue, we updated the kernel parameter metadata so that the input type argument now calls `type` (configured as an alias) rather than the model’s parameter `type_`. Previously, setting the alias did not update the underlying `type_` attribute, leaving it as `None`. As a result, when generating the JSON schema, the `parameter_type` was omitted, causing some customers who sent `KernelFunctionMetadata` to the OpenAI model to receive a 400 error due to a malformed schema. <!-- 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. --> ### Description Revert the change and add a unit test to make sure we check for the expected schema. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### 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 😄
1 parent e183399 commit 68448b1

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

python/semantic_kernel/prompt_template/prompt_template_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get_kernel_parameter_metadata(self) -> Sequence[KernelParameterMetadata]:
8383
name=variable.name,
8484
description=variable.description,
8585
default_value=variable.default,
86-
type=variable.json_schema, # TODO (moonbox3): update to handle complex JSON schemas
86+
type_=variable.json_schema, # TODO (moonbox3): update to handle complex JSON schemas # type: ignore
8787
is_required=variable.is_required,
8888
)
8989
for variable in self.input_variables

python/tests/unit/prompt_template/test_prompt_templates.py

+1
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,4 @@ def test_from_yaml_with_function_choice_behavior():
326326
def test_multiple_param_in_prompt():
327327
func = KernelFunctionFromPrompt("test", prompt="{{$param}}{{$param}}")
328328
assert len(func.parameters) == 1
329+
assert func.metadata.parameters[0].schema_data == {"type": "object"}

0 commit comments

Comments
 (0)