Promote Azure served model header for Responses - #3545
Conversation
Promote non-empty x-ms-served-model values into Azure Responses model fields before response construction. This keeps the behavior scoped to Azure clients and covers both parsed Responses objects and streamed response events without touching generated resource files. Add sync and async Azure regression coverage for non-streaming and streaming Responses calls.
jbeckwith-oai
left a comment
There was a problem hiding this comment.
The production change is focused and behaves correctly in the exercised sync/async and streaming paths, but the test structure needs one cleanup before merge.
tests/lib/test_azure.py grows from 955 to 1,084 lines in this PR, crossing the 1k-line boundary, and the added 130 lines repeat nearly identical client/router setup across four tests. Please move this feature coverage into a focused module (for example, tests/lib/test_azure_responses.py) or collapse the duplication with shared fixtures/helpers so the existing catch-all file does not keep sprawling past 1k lines. This is a clear decomposition boundary and will also make the important absent/blank-header and non-Responses guards easier to cover without making the original file larger.
Validation on exact head d5a658b6125d5d877aaf04c9b6db72eae4255fcb: all 63 Azure tests passed; Ruff lint and format checks passed; Pyright passed; mypy passed; git diff --check passed.
Move Azure Responses served-model header coverage out of the catch-all Azure test module into a focused tests/lib/test_azure_responses.py module. Keep tests/lib/test_azure.py below the 1k-line decomposition boundary and add focused guard coverage for absent or blank served-model headers and non-Responses resources. Verification: .venv/bin/python -m pytest -o addopts= tests/lib/test_azure_responses.py tests/lib/test_azure.py -q; .venv/bin/ruff check src/openai/lib/azure.py tests/lib/test_azure.py tests/lib/test_azure_responses.py; .venv/bin/ruff format --check src/openai/lib/azure.py tests/lib/test_azure.py tests/lib/test_azure_responses.py; git diff --check; PATH=.venv/bin:/opt/homebrew/opt/python@3.13/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Library/Apple/usr/bin:/Users/BigMomma/.volta/bin:/Applications/Docker.app/Contents/Resources/bin:/Users/BigMomma/.codex/tmp/arg0/codex-arg0QOxwtR:/Users/BigMomma/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin/override:/Users/BigMomma/.cargo/bin:/Users/BigMomma/.lmstudio/bin:/Users/BigMomma/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin/fallback:/Applications/ChatGPT.app/Contents/Resources scripts/run-pyright; .venv/bin/mypy .
|
Addressed in the latest push ( I moved the Azure Responses served-model coverage out of Local validation run:
|
Fixes #3271.
Summary
x-ms-served-modelresponse headers into Responses APIResponse.modelevent.response.modelTesting
.venv/bin/pytest tests/lib/test_azure.py -q -o addopts="".venv/bin/ruff check src/openai/lib/azure.py tests/lib/test_azure.py.venv/bin/ruff format --check src/openai/lib/azure.py tests/lib/test_azure.py.venv/bin/pyright --pythonpath .venv/bin/python src/openai/lib/azure.py tests/lib/test_azure.py.venv/bin/mypy src/openai/lib/azure.py