Commit e9c26d1e
Changed files (9)
.github
examples
src
openai
.github/workflows/create-releases.yml
@@ -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 }}
.github/workflows/publish-pypi.yml
@@ -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 }}
.github/workflows/release-doctor.yml
@@ -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 }}
bin/check-release-environment
@@ -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!"
bin/publish-pypi
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -eux
+mkdir -p dist
+rye build --clean
+rye publish --yes --token=$PYPI_TOKEN
examples/audio.py
@@ -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()
src/openai/_version.py
@@ -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
.release-please-manifest.json
@@ -0,0 +1,3 @@
+{
+ ".": "1.1.1"
+}
\ No newline at end of file
release-please-config.json
@@ -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"
+ ]
+}
\ No newline at end of file