From 063f7d0684c350ca9d766e2cb150233a22a623c8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 17:58:42 +0000 Subject: [PATCH 1/6] fix(client): remove duplicate types (#2235) --- src/openai/types/shared/all_models.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/openai/types/shared/all_models.py b/src/openai/types/shared/all_models.py index c4635e2140..db8410773e 100644 --- a/src/openai/types/shared/all_models.py +++ b/src/openai/types/shared/all_models.py @@ -8,9 +8,5 @@ __all__ = ["AllModels"] AllModels: TypeAlias = Union[ - str, - ChatModel, - str, - ChatModel, - Literal["o1-pro", "o1-pro-2025-03-19", "computer-use-preview", "computer-use-preview-2025-03-11"], + str, ChatModel, Literal["o1-pro", "o1-pro-2025-03-19", "computer-use-preview", "computer-use-preview-2025-03-11"] ] From fb109347567ba5b469528d325bf4cad0ca8da7da Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 18:06:44 -0400 Subject: [PATCH 2/6] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index abb9371314..2df281d34f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 82 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-c22f59c66aec7914b6ee653d3098d1c1c8c16c180d2a158e819c8ddbf476f74b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-5ad6884898c07591750dde560118baf7074a59aecd1f367f930c5e42b04e848a.yml From 8b04453f0483736c13f0209a9f8f3618bc0e86c9 Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Fri, 21 Mar 2025 13:32:27 +0000 Subject: [PATCH 3/6] fix(package): make sounddevice and numpy optional dependencies --- pyproject.toml | 3 +-- src/openai/_extras/__init__.py | 1 + src/openai/_extras/numpy_proxy.py | 2 +- src/openai/_extras/sounddevice_proxy.py | 28 ++++++++++++++++++++++++ src/openai/helpers/local_audio_player.py | 13 ++++++----- src/openai/helpers/microphone.py | 12 +++++----- 6 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 src/openai/_extras/sounddevice_proxy.py diff --git a/pyproject.toml b/pyproject.toml index 5ee7157038..f34bf6bfa3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,8 +16,6 @@ dependencies = [ "sniffio", "tqdm > 4", "jiter>=0.4.0, <1", - "sounddevice>=0.5.1", - "numpy>=2.0.2", ] requires-python = ">= 3.8" classifiers = [ @@ -47,6 +45,7 @@ openai = "openai.cli:main" [project.optional-dependencies] realtime = ["websockets >= 13, < 15"] datalib = ["numpy >= 1", "pandas >= 1.2.3", "pandas-stubs >= 1.1.0.11"] +audio = ["sounddevice>=0.5.1", "numpy>=2.0.2"] [tool.rye] managed = true diff --git a/src/openai/_extras/__init__.py b/src/openai/_extras/__init__.py index 864dac4171..692de248c0 100644 --- a/src/openai/_extras/__init__.py +++ b/src/openai/_extras/__init__.py @@ -1,2 +1,3 @@ from .numpy_proxy import numpy as numpy, has_numpy as has_numpy from .pandas_proxy import pandas as pandas +from .sounddevice_proxy import sounddevice as sounddevice diff --git a/src/openai/_extras/numpy_proxy.py b/src/openai/_extras/numpy_proxy.py index 27880bf132..8412965e44 100644 --- a/src/openai/_extras/numpy_proxy.py +++ b/src/openai/_extras/numpy_proxy.py @@ -10,7 +10,7 @@ import numpy as numpy -NUMPY_INSTRUCTIONS = format_instructions(library="numpy", extra="datalib") +NUMPY_INSTRUCTIONS = format_instructions(library="numpy", extra="audio") class NumpyProxy(LazyProxy[Any]): diff --git a/src/openai/_extras/sounddevice_proxy.py b/src/openai/_extras/sounddevice_proxy.py new file mode 100644 index 0000000000..0894782bd5 --- /dev/null +++ b/src/openai/_extras/sounddevice_proxy.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any +from typing_extensions import override + +from .._utils import LazyProxy +from ._common import MissingDependencyError, format_instructions + +if TYPE_CHECKING: + import sounddevice as sounddevice # type: ignore + + +SOUNDDEVICE_INSTRUCTIONS = format_instructions(library="sounddevice", extra="audio") + + +class SounddeviceProxy(LazyProxy[Any]): + @override + def __load__(self) -> Any: + try: + import sounddevice # type: ignore + except ImportError as err: + raise MissingDependencyError(SOUNDDEVICE_INSTRUCTIONS) from err + + return sounddevice + + +if not TYPE_CHECKING: + sounddevice = SounddeviceProxy() diff --git a/src/openai/helpers/local_audio_player.py b/src/openai/helpers/local_audio_player.py index 46a16ce6bb..eed68aa21d 100644 --- a/src/openai/helpers/local_audio_player.py +++ b/src/openai/helpers/local_audio_player.py @@ -1,15 +1,18 @@ # mypy: ignore-errors +from __future__ import annotations + import queue import asyncio from typing import Any, Union, Callable, AsyncGenerator, cast - -import numpy as np -import sounddevice as sd # type: ignore -import numpy.typing as npt +from typing_extensions import TYPE_CHECKING from .. import _legacy_response +from .._extras import numpy as np, sounddevice as sd from .._response import StreamedBinaryAPIResponse, AsyncStreamedBinaryAPIResponse +if TYPE_CHECKING: + import numpy.typing as npt + SAMPLE_RATE = 24000 @@ -62,7 +65,7 @@ async def play( if input.dtype == np.int16 and self.dtype == np.float32: audio_content = (input.astype(np.float32) / 32767.0).reshape(-1, self.channels) elif input.dtype == np.float32: - audio_content = cast(npt.NDArray[np.float32], input) + audio_content = cast('npt.NDArray[np.float32]', input) else: raise ValueError(f"Unsupported dtype: {input.dtype}") else: diff --git a/src/openai/helpers/microphone.py b/src/openai/helpers/microphone.py index 18650909aa..62a6d8d8a9 100644 --- a/src/openai/helpers/microphone.py +++ b/src/openai/helpers/microphone.py @@ -1,16 +1,18 @@ # mypy: ignore-errors +from __future__ import annotations + import io import time import wave import asyncio from typing import Any, Type, Union, Generic, TypeVar, Callable, overload -from typing_extensions import Literal +from typing_extensions import TYPE_CHECKING, Literal -import numpy as np -import sounddevice as sd # type: ignore -import numpy.typing as npt +from .._types import FileTypes, FileContent +from .._extras import numpy as np, sounddevice as sd -from openai._types import FileTypes, FileContent +if TYPE_CHECKING: + import numpy.typing as npt SAMPLE_RATE = 24000 From 67f89d478aab780d1481c9bf6682c6633e431137 Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Fri, 21 Mar 2025 13:33:45 +0000 Subject: [PATCH 4/6] chore(ci): run workflows on next too --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06eb10c5f0..d86fc0ea53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,7 @@ on: pull_request: branches: - main + - next jobs: lint: From f253d0415145f2c4904ea2e7b389d31d94e45a54 Mon Sep 17 00:00:00 2001 From: Robert Craigie Date: Fri, 21 Mar 2025 13:41:53 +0000 Subject: [PATCH 5/6] fix(helpers/audio): remove duplicative module --- src/openai/helpers.py | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/openai/helpers.py diff --git a/src/openai/helpers.py b/src/openai/helpers.py deleted file mode 100644 index 1a10168a96..0000000000 --- a/src/openai/helpers.py +++ /dev/null @@ -1,4 +0,0 @@ -from .helpers.microphone import Microphone -from .helpers.local_audio_player import LocalAudioPlayer - -__all__ = ["LocalAudioPlayer", "Microphone"] From cb2d417c2ba36aa1d77ade5ecc92e9658d41802c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 13:42:29 +0000 Subject: [PATCH 6/6] release: 1.68.1 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 15 +++++++++++++++ pyproject.toml | 2 +- src/openai/_version.py | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 42bc7e250e..2ec6ee54df 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.68.0" + ".": "1.68.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 78ae21f27f..d26a769784 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 1.68.1 (2025-03-21) + +Full Changelog: [v1.68.0...v1.68.1](https://github.com/openai/openai-python/compare/v1.68.0...v1.68.1) + +### Bug Fixes + +* **client:** remove duplicate types ([#2235](https://github.com/openai/openai-python/issues/2235)) ([063f7d0](https://github.com/openai/openai-python/commit/063f7d0684c350ca9d766e2cb150233a22a623c8)) +* **helpers/audio:** remove duplicative module ([f253d04](https://github.com/openai/openai-python/commit/f253d0415145f2c4904ea2e7b389d31d94e45a54)) +* **package:** make sounddevice and numpy optional dependencies ([8b04453](https://github.com/openai/openai-python/commit/8b04453f0483736c13f0209a9f8f3618bc0e86c9)) + + +### Chores + +* **ci:** run workflows on next too ([67f89d4](https://github.com/openai/openai-python/commit/67f89d478aab780d1481c9bf6682c6633e431137)) + ## 1.68.0 (2025-03-20) Full Changelog: [v1.67.0...v1.68.0](https://github.com/openai/openai-python/compare/v1.67.0...v1.68.0) diff --git a/pyproject.toml b/pyproject.toml index f34bf6bfa3..57871a46fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openai" -version = "1.68.0" +version = "1.68.1" description = "The official Python library for the openai API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/openai/_version.py b/src/openai/_version.py index 23e4e7ffb7..1f00359eb1 100644 --- a/src/openai/_version.py +++ b/src/openai/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "openai" -__version__ = "1.68.0" # x-release-please-version +__version__ = "1.68.1" # x-release-please-version