Repository navigation
fix(examples): refresh chat streaming examples - #2974
Conversation
- Replace `poetry run python` shebangs with `rye run python` to match the project's current tooling (demo.py, async_demo.py, streaming.py, video.py) - Migrate async_demo.py and streaming.py from the legacy Completions API (`client.completions.create` with gpt-3.5-turbo-instruct) to the Chat Completions API (`client.chat.completions.create`) - Update model references from gpt-4 to gpt-4o in demo.py
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. |
Castiron custom code✅ No new custom-code files detected. 43 mixed files remain; 0 existing customizations changed. Compared 43 existing customizations unchanged
3 more in the full report. 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 35005415842 --repo openai/openai-python \
--name castiron-custom-code-35005415842-1 --dir /tmp/castiron-custom-code-35005415842-1
git apply --stat /tmp/castiron-custom-code-35005415842-1/custom-code.patch
cat /tmp/castiron-custom-code-35005415842-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin 1493321affb1814fba7b669892e376a119d8d36f c910067f18428a0f681181e16d40677ce9c99b0e
python3 scripts/castiron/custom_code_report.py report \
--base 1493321affb1814fba7b669892e376a119d8d36f \
--head c910067f18428a0f681181e16d40677ce9c99b0e --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-c910067f1842
cat /tmp/castiron-custom-code-c910067f1842/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
|
Thanks for updating the streaming examples. streaming.py still uses legacy Completions, and the async demo prints |
Automated Release PR --- ## [3.14.1](openai/openai-python@v3.14.0...v3.14.1) (2026-09-15) ### Bug Fixes * **client:** validate retry limits and preserve application errors ([openai#3867](openai#3867)) ([f86c721](openai@f86c721)) * correct typo "th" to "the" in StreamAlreadyConsumed error message ([openai#3022](openai#3022)) ([7186203](openai@7186203)) * **examples:** correct Azure endpoint hostname ([openai#3298](openai#3298)) ([543516c](openai@543516c)) * **examples:** refresh chat streaming examples ([openai#2974](openai#2974)) ([54f460e](openai@54f460e)) * **examples:** split push-to-talk shebang arguments ([openai#3210](openai#3210)) ([d241ed6](openai@d241ed6)) * **examples:** use uv in remaining Python launchers ([openai#3821](openai#3821)) ([8c76c4f](openai@8c76c4f)) * log only metadata for Live WebSocket diagnostics ([openai#3865](openai#3865)) ([ccc10f5](openai@ccc10f5)) * **responses:** skip structured parsing for commentary ([openai#3861](openai#3861)) ([6520df1](openai@6520df1)) ### Chores * **examples:** bump module_client.py to gpt-5.6 ([openai#3211](openai#3211)) ([1493321](openai@1493321)) * remove unused fine-tuning data validators ([openai#3863](openai#3863)) ([9640f29](openai@9640f29)) ### Documentation * clarify async client cleanup ([openai#2388](openai#2388)) ([a3d83b5](openai@a3d83b5)) * clarify filenames for in-memory file uploads ([openai#3729](openai#3729)) ([cb27380](openai@cb27380)) * **client:** correct retry jitter comment ([openai#2252](openai#2252)) ([bdbbc16](openai@bdbbc16)) * fix Realtime docstring wording ([openai#3535](openai#3535)) ([8cb9ded](openai@8cb9ded)) * fix reusing wording in Azure client docstrings ([openai#3061](openai#3061)) ([dc625f9](openai@dc625f9)) * fix streaming comment typo ([openai#3005](openai#3005)) ([d421d7a](openai@d421d7a)) * fix vector store polling helper paths ([openai#3101](openai#3101)) ([2ef2de6](openai@2ef2de6)) * **readme:** correct SSE terminology ([openai#2837](openai#2837)) ([caaa9b4](openai@caaa9b4)) * update Responses API reference link ([openai#3279](openai#3279)) ([557bd06](openai@557bd06)) * **utils:** correct query component RFC reference ([openai#3300](openai#3300)) ([929a8a5](openai@929a8a5)) --- 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>
Summary
Several example scripts still reference
poetryin their shebangs and use the legacy Completions API, which is no longer documented in the README. This PR brings them up to date:Shebangs:
demo.py,async_demo.py,streaming.py, andvideo.pyall used#!/usr/bin/env -S poetry run python. The project migrated to Rye and other examples (e.g.audio.py,speech_to_text.py) already userye run python. Updated the four remaining files for consistency.Deprecated API:
async_demo.pyandstreaming.pyused the legacy Completions endpoint (client.completions.createwithgpt-3.5-turbo-instruct). This endpoint isn't referenced in the README andgpt-3.5-turbo-instructis one of the last models supporting it. Migrated both to the Chat Completions API (client.chat.completions.create).Model name:
demo.pyreferencedgpt-4. Updated togpt-4oto reflect current recommended usage.Changes
examples/demo.pypoetry→rye, modelgpt-4→gpt-4oexamples/async_demo.pypoetry→rye,completions.create→chat.completions.createexamples/streaming.pypoetry→rye,completions.create→chat.completions.createexamples/video.pypoetry→ryeTest plan
ruff checkpasses on all modified filesruff format --checkpasses on all modified filestests/test_streaming.py) passimport openaiworks correctly