Transform Pydantic output config formats - #1821
Open
uuzzrm wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1819.
output_config.formatnow accepts the same Pydantic model input that the deprecatedoutput_formatparameter accepted, and sends model-generated schemas through the existingtransform_schemapath before request serialization. Raw JSON schema dictionaries remain unchanged and continue to be sent as provided.The conversion is applied consistently to the stable and beta Messages APIs for synchronous and asynchronous
create,parse,stream, andcount_tokenscalls. The publicOutputConfigParamtypes now include Pydantic model classes.The change is intentionally scoped to the Messages API surfaces covered by this issue; Message Batches and refusal fallbacks are unchanged.
Tests
uv run pytest tests/lib/_parse/test_transform.py tests/api_resources/test_output_config_format_conversion.py -q— 32 passed, 1 skippedgit diff --checkpassedThe repository test wrapper could not start its mock server on this machine because Node is missing
libllhttp.9.3.dylib; the targeted tests ran without that wrapper.AI assistance was used for implementation and validation. The final diff was checked against the issue and the targeted test results before this update.