refactor(api): share embedding response decoding - #3699
Conversation
Castiron custom code✅ No new custom-code files detected. 41 mixed files remain; 1 existing customization changed. Compared
40 existing customizations unchanged
A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload the exact patch produced by this run (requires repository access): gh run download 32425315692 --repo openai/openai-python \
--name castiron-custom-code-32425315692-1 --dir /tmp/castiron-custom-code-32425315692-1
git apply --stat /tmp/castiron-custom-code-32425315692-1/custom-code.patch
cat /tmp/castiron-custom-code-32425315692-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin 8edd9ae411f9d0a5385447a4697c9f7042868213 38cf9c9ccb2c4e007ada4672424733845e0c29e9
python3 scripts/castiron/custom_code_report.py report \
--base 8edd9ae411f9d0a5385447a4697c9f7042868213 \
--head 38cf9c9ccb2c4e007ada4672424733845e0c29e9 --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-38cf9c9ccb2c
cat /tmp/castiron-custom-code-38cf9c9ccb2c/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Independently reviewed the full diff and regression coverage. The shared embedding-response decoder preserves sync/async semantics, explicit encoding behavior, NumPy/stdlib decoding, validation errors, and response identity while moving SDK-owned logic out of generated resources.
Automated Release PR --- ## [3.4.0](openai/openai-python@v3.3.1...v3.4.0) (2026-08-25) ### Features * **api:** Add obfuscation field to ChatCompletionChunk ([openai#3690](openai#3690)) ([c7d8e1d](openai@c7d8e1d)) * **api:** add project residency configuration and cost quantity units ([openai#3726](openai#3726)) ([bc4f8ef](openai@bc4f8ef)) ### Bug Fixes * **api:** encode Realtime call offers and session configuration ([openai#3736](openai#3736)) ([555ac48](openai@555ac48)) * apply consistent origin checks to WebSocket redirects ([openai#3693](openai#3693)) ([1b324d0](openai@1b324d0)) * **azure:** encode deployment names consistently ([openai#3683](openai#3683)) ([689538d](openai@689538d)) * **azure:** keep provider validation errors value-free ([openai#3691](openai#3691)) ([72529c0](openai@72529c0)) * **azure:** resolve one authentication mode ([openai#3689](openai#3689)) ([e3d0681](openai@e3d0681)) * compute custom-code summaries from trusted workflow code ([openai#3692](openai#3692)) ([2b5868d](openai@2b5868d)) * create upload example fixtures in private directories ([openai#3686](openai#3686)) ([f36e6f7](openai@f36e6f7)) * decode SSE incrementally without limiting event size ([openai#3687](openai#3687)) ([2598d53](openai@2598d53)) * keep Python SDK diagnostics metadata-only ([openai#3685](openai#3685)) ([600aa8d](openai@600aa8d)) * Preserve Azure authentication boundaries across transports ([openai#3684](openai#3684)) ([06ef57c](openai@06ef57c)) * preserve the configured TLS hostname ([openai#3694](openai#3694)) ([aa5fbc4](openai@aa5fbc4)) * preserve WebSocket send queue byte accounting during flush ([openai#3688](openai#3688)) ([96f966d](openai@96f966d)) ### Chores * **api:** Clarify image background docs and preview support ([openai#3703](openai#3703)) ([bedb9a7](openai@bedb9a7)) * **api:** document supported image generation models ([openai#3695](openai#3695)) ([8edd9ae](openai@8edd9ae)) * **api:** move chat validation tests out of generated code ([openai#3698](openai#3698)) ([9d3ba20](openai@9d3ba20)) * **api:** move webhook tests out of generated code ([openai#3700](openai#3700)) ([04ecb3c](openai@04ecb3c)) * **api:** remove redundant generated formatting ([openai#3696](openai#3696)) ([5ac1e03](openai@5ac1e03)) * **api:** remove redundant generated test edits ([openai#3697](openai#3697)) ([351ef84](openai@351ef84)) * **api:** Update SDK generation metadata only ([openai#3716](openai#3716)) ([e43b422](openai@e43b422)) * set a ceiling for Python SDK customization ([openai#3714](openai#3714)) ([04d5d79](openai@04d5d79)) ### Documentation * **api:** restore generated ChatKit API index ([openai#3705](openai#3705)) ([4534106](openai@4534106)) * standardize Python SDK vulnerability disclosure policy ([openai#3642](openai#3642)) ([1fc0a21](openai@1fc0a21)) ### Refactors * **api:** isolate audio response format selection ([openai#3701](openai#3701)) ([ece4324](openai@ece4324)) * **api:** isolate vector-store polling helpers ([openai#3713](openai#3713)) ([a002ef3](openai@a002ef3)) * **api:** move file processing polling into SDK-owned helpers ([openai#3712](openai#3712)) ([5f20c51](openai@5f20c51)) * **api:** share embedding response decoding ([openai#3699](openai#3699)) ([50de9af](openai@50de9af)) * **api:** share webhook signature verification ([openai#3704](openai#3704)) ([e14ac34](openai@e14ac34)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
Changes being requested
Move the duplicated embeddings response decoder into the SDK-owned
lib/_parsing/_embeddings.pymodule. Both resource methods use the existingpost_parserhook. The decoder logic is unchanged: omitted encoding requestsbase64 and decodes it in place; explicit formats pass through; empty data keeps
the existing
ValueError; NumPy and stdlib decoding keep their existing errors.Public signatures, exports, request fields and order, sync/async behavior, and
raw/streaming response wrappers are unchanged. No compiler, schema, dependency,
or generation-metadata changes are included.
Additional context & links
New handwritten coverage is in
tests/lib/test_embeddings.py:test_decode_preserves_response_and_non_string_vectorschecks in-placedecoding, both omitted-value sentinels, and untouched non-string vectors.
test_explicit_format_is_untouched,test_missing_data_keeps_existing_error, andtest_invalid_data_preserves_decoder_errorscover passthrough and failures.test_sync_create_uses_decoderandtest_async_create_uses_decodercovernormal, raw, and streaming responses with both decoder implementations.
Validation:
python -m pytest -q -n 4 tests/api_resources/test_embeddings.py tests/lib/test_embeddings.pypassed 77 tests under Pydantic v2 and 77 under Pydantic v1.
./scripts/formatand./scripts/lintpassed, including Ruff, Pyright, mypy,and import checks. Unrelated formatter-only reporter edits are excluded.
./scripts/buildpassed; the wheel and source distribution both contain thenew private helper.
customization changed, and 40 other customizations unchanged. The embeddings
patch shrinks from +73/-22 to +27/-21.
.castiron.stats.ymlis unchanged.Command to reproduce the report from this branch:
$ python3 scripts/castiron/custom_code_report.py report \ --base 8edd9ae411f9d0a5385447a4697c9f7042868213 \ --head 38cf9c9ccb2c4e007ada4672424733845e0c29e9 \ --fetch --require-head-hash --public \ --out /tmp/castiron-embedding-decoder