Skip to content

fix(extra): return ResponseFormatTypedDict from response_format_from_pydantic_model#438

Merged
Nelson-PROIA merged 2 commits intomainfrom
nelson.proia/air-143-azure-response-format-dict
Mar 20, 2026
Merged

fix(extra): return ResponseFormatTypedDict from response_format_from_pydantic_model#438
Nelson-PROIA merged 2 commits intomainfrom
nelson.proia/air-143-azure-response-format-dict

Conversation

@Nelson-PROIA
Copy link
Contributor

@Nelson-PROIA Nelson-PROIA commented Mar 19, 2026

Summary

  • response_format_from_pydantic_model now returns a ResponseFormatTypedDict (plain dict at runtime) instead of a ResponseFormat model instance
  • Fixes the type mismatch when Azure/GCP SDK users pass the result to ocr.process() or chat.complete(), which expect their own ResponseFormat class
  • Also fixes the schema alias data loss issue (no more need for .model_dump(by_alias=True))
  • Dict uses schema key (wire format) so it works both through SDK serialization and when passed directly (batch jobs, raw HTTP)
  • Fixes list[Tool] mypy error in function_calling.py example (list invariance with broadened union type from SDK 2.1.0)

Test plan

Closes #367

@louis-sanna-dev
Copy link
Contributor

@Nelson-PROIA have we tested it works on a live azure endpoint?

@Nelson-PROIA Nelson-PROIA force-pushed the nelson.proia/air-143-azure-response-format-dict branch 2 times, most recently from e88b68f to 52982af Compare March 20, 2026 10:59
…pydantic_model

response_format_from_pydantic_model now returns a ResponseFormatTypedDict
(plain dict) instead of a ResponseFormat model instance. This fixes the
type mismatch when passing the result to the Azure SDK, which expects its
own ResponseFormat class, and avoids the schema alias data loss issue.

Fixes AIR-143 / GitHub #367
Fix mypy list invariance error introduced by SDK 2.1.0 regen where
list[Tool] no longer satisfies the broadened tools union type.
@Nelson-PROIA Nelson-PROIA force-pushed the nelson.proia/air-143-azure-response-format-dict branch from 52982af to 4fb65be Compare March 20, 2026 11:15
@Nelson-PROIA Nelson-PROIA merged commit 793c3ac into main Mar 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG CLIENT]: OCR data extraction example gives an ValidationError: 2 validation errors for Unmarshaller Azure Foundry Model

2 participants