mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
Python: fix: Remove wrong response_format override in AzureChatPromptExecutionSettings class (#6424)
### Motivation and Context This change is required to fix #5997 ### Description The change is removing the wrong `response_format` override in `AzureChatPromptExecutionSettings` class. The PR is also adding a unit test covering the case where `response format` is defined. The changes were successfully tested against an `Azure OpenAI` instance with a `gpt-4o` deployment by specifying an `AzureChatPromptExecutionSettings` like follows: ```python execution_settings = AzureChatPromptExecutionSettings( service_id=service_id, ai_model_id=ai_model_id, max_tokens=1000, temperature=0.2, response_format={"type": "json_object"}, ) ``` ### 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 😄 Co-authored-by: Evan Mattson <[email protected]>
This commit is contained in:
co-authored by
Evan Mattson
parent
e03b3fa168
commit
5d25f6a8dd
-1
@@ -99,5 +99,4 @@ class ExtraBody(KernelBaseModel):
|
||||
class AzureChatPromptExecutionSettings(OpenAIChatPromptExecutionSettings):
|
||||
"""Specific settings for the Azure OpenAI Chat Completion endpoint."""
|
||||
|
||||
response_format: str | None = None
|
||||
extra_body: dict[str, Any] | ExtraBody | None = None
|
||||
|
||||
@@ -263,3 +263,10 @@ def test_azure_open_ai_chat_prompt_execution_settings_with_aisearch_data_sources
|
||||
}
|
||||
settings = AzureChatPromptExecutionSettings.model_validate(input_dict, strict=True, from_attributes=True)
|
||||
assert settings.extra_body["dataSources"][0]["type"] == "AzureCognitiveSearch"
|
||||
|
||||
|
||||
def test_azure_open_ai_chat_prompt_execution_settings_with_response_format_json():
|
||||
response_format = {"type": "json_object"}
|
||||
settings = AzureChatPromptExecutionSettings(response_format=response_format)
|
||||
options = settings.prepare_settings_dict()
|
||||
assert options["response_format"] == response_format
|
||||
|
||||
Reference in New Issue
Block a user