feat(ext): support structured output in AzureAIChatCompletionClient - #8065
feat(ext): support structured output in AzureAIChatCompletionClient#8065Siddhesh Kabra (Xsidz) wants to merge 3 commits into
Conversation
Fixes microsoft#5957 Replaces the TODO/raise-ValueError block with actual structured output support: when json_output is a Pydantic BaseModel subclass, builds a JsonSchemaFormat from the model's JSON schema and sets it as response_format, matching the OpenAIChatCompletionClient pattern.
|
Siddhesh Kabra (@Xsidz) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
Siddhesh Kabra (@Xsidz) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
@microsoft-github-policy-service agree |
Summary
Fixes #5957
Removes the TODO/raise-ValueError block in
AzureAIChatCompletionClient._validate_model_infoand replaces it with actual structured output support, mirroring theOpenAIChatCompletionClientpattern.Change in
_azure_ai_client.py:JsonSchemaFormatfromazure.ai.inference.modelsjson_outputis a PydanticBaseModelsubclass, validatesmodel_info["structured_output"]isTrue, then builds aJsonSchemaFormatfromjson_output.model_json_schema()and sets it ascreate_args["response_format"]ChatCompletionsClient.complete()already acceptsresponse_format: JsonSchemaFormatdirectlyUsage after this change:
Test plan
test_structured_output_raises_when_not_supported: verifies ValueError whenmodel_info["structured_output"]is Falsetest_structured_output_sets_json_schema_format: verifiesJsonSchemaFormatis set with correct name and schematest_azure_ai_model_client.py: 20 passed, 0 failures