-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0aafc6
commit e9c26d1
Showing
9 changed files
with
220 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Create releases | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
name: release | ||
if: github.ref == 'refs/heads/main' && github.repository == 'openai/openai-python' | ||
runs-on: ubuntu-latest | ||
environment: publish | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: stainless-api/trigger-release-please@v1 | ||
id: release | ||
with: | ||
repo: ${{ github.event.repository.full_name }} | ||
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} | ||
|
||
- name: Install Rye | ||
if: ${{ steps.release.outputs.releases_created }} | ||
run: | | ||
curl -sSf https://rye-up.com/get | bash | ||
echo "$HOME/.rye/shims" >> $GITHUB_PATH | ||
env: | ||
RYE_VERSION: 0.15.2 | ||
RYE_INSTALL_OPTION: "--yes" | ||
|
||
- name: Publish to PyPI | ||
if: ${{ steps.release.outputs.releases_created }} | ||
run: | | ||
bash ./bin/publish-pypi | ||
env: | ||
PYPI_TOKEN: ${{ secrets.OPENAI_PYPI_TOKEN || secrets.PYPI_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# workflow for re-running publishing to PyPI in case it fails for some reason | ||
# you can run this workflow by navigating to https://www.github.com/openai/openai-python/actions/workflows/publish-pypi.yml | ||
name: Publish PyPI | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
name: publish | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Rye | ||
run: | | ||
curl -sSf https://rye-up.com/get | bash | ||
echo "$HOME/.rye/shims" >> $GITHUB_PATH | ||
env: | ||
RYE_VERSION: 0.15.2 | ||
RYE_INSTALL_OPTION: "--yes" | ||
|
||
- name: Publish to PyPI | ||
run: | | ||
bash ./bin/publish-pypi | ||
env: | ||
PYPI_TOKEN: ${{ secrets.OPENAI_PYPI_TOKEN || secrets.PYPI_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Release Doctor | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release_doctor: | ||
name: release doctor | ||
runs-on: ubuntu-latest | ||
environment: publish | ||
if: github.repository == 'openai/openai-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Check release environment | ||
run: | | ||
bash ./bin/check-release-environment | ||
env: | ||
STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} | ||
PYPI_TOKEN: ${{ secrets.OPENAI_PYPI_TOKEN || secrets.PYPI_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
".": "1.1.1" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
errors=() | ||
|
||
if [ -z "${STAINLESS_API_KEY}" ]; then | ||
errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.") | ||
fi | ||
|
||
if [ -z "${PYPI_TOKEN}" ]; then | ||
errors+=("The OPENAI_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.") | ||
fi | ||
|
||
len=${#errors[@]} | ||
|
||
if [[ len -gt 0 ]]; then | ||
echo -e "Found the following errors in the release environment:\n" | ||
|
||
for error in "${errors[@]}"; do | ||
echo -e "- $error\n" | ||
done | ||
|
||
exit 1 | ||
fi | ||
|
||
echo "The environment is ready to push releases!" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
mkdir -p dist | ||
rye build --clean | ||
rye publish --yes --token=$PYPI_TOKEN |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python | ||
|
||
from pathlib import Path | ||
|
||
from openai import OpenAI | ||
|
||
# gets OPENAI_API_KEY from your environment variables | ||
openai = OpenAI() | ||
|
||
speech_file_path = Path(__file__).parent / "speech.mp3" | ||
|
||
|
||
def main() -> None: | ||
# Create text-to-speech audio file | ||
response = openai.audio.speech.create( | ||
model="tts-1", voice="alloy", input="the quick brown fox jumped over the lazy dogs" | ||
) | ||
|
||
response.stream_to_file(speech_file_path) | ||
|
||
# Create transcription from audio file | ||
transcription = openai.audio.transcriptions.create(model="whisper-1", file=speech_file_path) | ||
print(transcription.text) | ||
|
||
# Create translation from audio file | ||
translation = openai.audio.translations.create( | ||
model="whisper-1", | ||
file=speech_file_path, | ||
) | ||
print(translation.text) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"packages": { | ||
".": {} | ||
}, | ||
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", | ||
"include-v-in-tag": true, | ||
"include-component-in-tag": false, | ||
"bump-minor-pre-major": true, | ||
"bump-patch-for-minor-pre-major": false, | ||
"pull-request-header": "Automated Release PR", | ||
"pull-request-title-pattern": "release: ${version}", | ||
"changelog-sections": [ | ||
{ | ||
"type": "feat", | ||
"section": "Features" | ||
}, | ||
{ | ||
"type": "fix", | ||
"section": "Bug Fixes" | ||
}, | ||
{ | ||
"type": "perf", | ||
"section": "Performance Improvements" | ||
}, | ||
{ | ||
"type": "revert", | ||
"section": "Reverts" | ||
}, | ||
{ | ||
"type": "chore", | ||
"section": "Chores" | ||
}, | ||
{ | ||
"type": "docs", | ||
"section": "Documentation" | ||
}, | ||
{ | ||
"type": "style", | ||
"section": "Styles" | ||
}, | ||
{ | ||
"type": "refactor", | ||
"section": "Refactors" | ||
}, | ||
{ | ||
"type": "test", | ||
"section": "Tests", | ||
"hidden": true | ||
}, | ||
{ | ||
"type": "build", | ||
"section": "Build System" | ||
}, | ||
{ | ||
"type": "ci", | ||
"section": "Continuous Integration", | ||
"hidden": true | ||
} | ||
], | ||
"release-type": "python", | ||
"extra-files": [ | ||
"src/openai/_version.py" | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# File generated from our OpenAPI spec by Stainless. | ||
|
||
__title__ = "openai" | ||
__version__ = "1.1.1" | ||
__version__ = "1.1.1" # x-release-please-version |