fix(examples): update outdated shebangs and deprecated API usage#2974
Open
edenfunf wants to merge 1 commit intoopenai:mainfrom
Open
fix(examples): update outdated shebangs and deprecated API usage#2974edenfunf wants to merge 1 commit intoopenai:mainfrom
edenfunf wants to merge 1 commit intoopenai:mainfrom
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
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.
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