Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 1.48.0 #1742

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.47.1"
".": "1.48.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-de1981b64ac229493473670d618500c6362c195f1057eb7de00bd1bc9184fbd5.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-073331021d48db6af646a3552ab0c682efe31b7fb4e59a109ed1ba539f9b89c5.yml
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 1.48.0 (2024-09-25)

Full Changelog: [v1.47.1...v1.48.0](https://github.com/openai/openai-python/compare/v1.47.1...v1.48.0)

### Features

* **client:** allow overriding retry count header ([#1745](https://github.com/openai/openai-python/issues/1745)) ([9f07d4d](https://github.com/openai/openai-python/commit/9f07d4dbd6f24108a1f5e0309037318858f5a229))


### Bug Fixes

* **audio:** correct response_format translations type ([#1743](https://github.com/openai/openai-python/issues/1743)) ([b912108](https://github.com/openai/openai-python/commit/b9121089c696bc943323e2e75d4706401d809aaa))


### Chores

* **internal:** use `typing_extensions.overload` instead of `typing` ([#1740](https://github.com/openai/openai-python/issues/1740)) ([2522bd5](https://github.com/openai/openai-python/commit/2522bd59f7b5e903e4fc856a4c5dbdbe66bba37f))

## 1.47.1 (2024-09-23)

Full Changelog: [v1.47.0...v1.47.1](https://github.com/openai/openai-python/compare/v1.47.0...v1.47.1)
Expand Down
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Methods:
Types:

```python
from openai.types import AudioModel
from openai.types import AudioModel, AudioResponseFormat
```

## Transcriptions
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openai"
version = "1.47.1"
version = "1.48.0"
description = "The official Python library for the openai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
6 changes: 4 additions & 2 deletions src/openai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,10 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0
if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
headers[idempotency_header] = options.idempotency_key or self._idempotency_key()

if retries_taken > 0:
headers.setdefault("x-stainless-retry-count", str(retries_taken))
# Don't set the retry count header if it was already set or removed by the caller. We check
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
if "x-stainless-retry-count" not in (header.lower() for header in custom_headers):
headers["x-stainless-retry-count"] = str(retries_taken)

return headers

Expand Down
2 changes: 1 addition & 1 deletion src/openai/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "openai"
__version__ = "1.47.1" # x-release-please-version
__version__ = "1.48.0" # x-release-please-version
14 changes: 8 additions & 6 deletions src/openai/resources/audio/transcriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import httpx

from ... import _legacy_response
from ...types import AudioResponseFormat
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ..._utils import (
extract_files,
Expand All @@ -22,6 +23,7 @@
from ..._base_client import make_request_options
from ...types.audio_model import AudioModel
from ...types.audio.transcription import Transcription
from ...types.audio_response_format import AudioResponseFormat

__all__ = ["Transcriptions", "AsyncTranscriptions"]

Expand Down Expand Up @@ -53,7 +55,7 @@ def create(
model: Union[str, AudioModel],
language: str | NotGiven = NOT_GIVEN,
prompt: str | NotGiven = NOT_GIVEN,
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,
response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
timestamp_granularities: List[Literal["word", "segment"]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand Down Expand Up @@ -83,8 +85,8 @@ def create(
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
should match the audio language.

response_format: The format of the transcript output, in one of these options: `json`, `text`,
`srt`, `verbose_json`, or `vtt`.
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
`verbose_json`, or `vtt`.

temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
output more random, while lower values like 0.2 will make it more focused and
Expand Down Expand Up @@ -160,7 +162,7 @@ async def create(
model: Union[str, AudioModel],
language: str | NotGiven = NOT_GIVEN,
prompt: str | NotGiven = NOT_GIVEN,
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | NotGiven = NOT_GIVEN,
response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
timestamp_granularities: List[Literal["word", "segment"]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand Down Expand Up @@ -190,8 +192,8 @@ async def create(
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
should match the audio language.

response_format: The format of the transcript output, in one of these options: `json`, `text`,
`srt`, `verbose_json`, or `vtt`.
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
`verbose_json`, or `vtt`.

temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
output more random, while lower values like 0.2 will make it more focused and
Expand Down
14 changes: 8 additions & 6 deletions src/openai/resources/audio/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import httpx

from ... import _legacy_response
from ...types import AudioResponseFormat
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ..._utils import (
extract_files,
Expand All @@ -21,6 +22,7 @@
from ..._base_client import make_request_options
from ...types.audio_model import AudioModel
from ...types.audio.translation import Translation
from ...types.audio_response_format import AudioResponseFormat

__all__ = ["Translations", "AsyncTranslations"]

Expand Down Expand Up @@ -51,7 +53,7 @@ def create(
file: FileTypes,
model: Union[str, AudioModel],
prompt: str | NotGiven = NOT_GIVEN,
response_format: str | NotGiven = NOT_GIVEN,
response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -75,8 +77,8 @@ def create(
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
should be in English.

response_format: The format of the transcript output, in one of these options: `json`, `text`,
`srt`, `verbose_json`, or `vtt`.
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
`verbose_json`, or `vtt`.

temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
output more random, while lower values like 0.2 will make it more focused and
Expand Down Expand Up @@ -143,7 +145,7 @@ async def create(
file: FileTypes,
model: Union[str, AudioModel],
prompt: str | NotGiven = NOT_GIVEN,
response_format: str | NotGiven = NOT_GIVEN,
response_format: AudioResponseFormat | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -167,8 +169,8 @@ async def create(
[prompt](https://platform.openai.com/docs/guides/speech-to-text/prompting)
should be in English.

response_format: The format of the transcript output, in one of these options: `json`, `text`,
`srt`, `verbose_json`, or `vtt`.
response_format: The format of the output, in one of these options: `json`, `text`, `srt`,
`verbose_json`, or `vtt`.

temperature: The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
output more random, while lower values like 0.2 will make it more focused and
Expand Down
4 changes: 2 additions & 2 deletions src/openai/resources/beta/threads/runs/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

import typing_extensions
from typing import List, Union, Iterable, Optional, overload
from typing import List, Union, Iterable, Optional
from functools import partial
from typing_extensions import Literal
from typing_extensions import Literal, overload

import httpx

Expand Down
4 changes: 2 additions & 2 deletions src/openai/resources/beta/threads/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from __future__ import annotations

from typing import Union, Iterable, Optional, overload
from typing import Union, Iterable, Optional
from functools import partial
from typing_extensions import Literal
from typing_extensions import Literal, overload

import httpx

Expand Down
4 changes: 2 additions & 2 deletions src/openai/resources/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import annotations

import inspect
from typing import Dict, List, Union, Iterable, Optional, overload
from typing_extensions import Literal
from typing import Dict, List, Union, Iterable, Optional
from typing_extensions import Literal, overload

import httpx
import pydantic
Expand Down
4 changes: 2 additions & 2 deletions src/openai/resources/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from __future__ import annotations

from typing import Dict, List, Union, Iterable, Optional, overload
from typing_extensions import Literal
from typing import Dict, List, Union, Iterable, Optional
from typing_extensions import Literal, overload

import httpx

Expand Down
1 change: 1 addition & 0 deletions src/openai/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from .batch_create_params import BatchCreateParams as BatchCreateParams
from .batch_request_counts import BatchRequestCounts as BatchRequestCounts
from .upload_create_params import UploadCreateParams as UploadCreateParams
from .audio_response_format import AudioResponseFormat as AudioResponseFormat
from .image_generate_params import ImageGenerateParams as ImageGenerateParams
from .upload_complete_params import UploadCompleteParams as UploadCompleteParams
from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams
Expand Down
7 changes: 4 additions & 3 deletions src/openai/types/audio/transcription_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from ..._types import FileTypes
from ..audio_model import AudioModel
from ..audio_response_format import AudioResponseFormat

__all__ = ["TranscriptionCreateParams"]

Expand Down Expand Up @@ -41,10 +42,10 @@ class TranscriptionCreateParams(TypedDict, total=False):
should match the audio language.
"""

response_format: Literal["json", "text", "srt", "verbose_json", "vtt"]
response_format: AudioResponseFormat
"""
The format of the transcript output, in one of these options: `json`, `text`,
`srt`, `verbose_json`, or `vtt`.
The format of the output, in one of these options: `json`, `text`, `srt`,
`verbose_json`, or `vtt`.
"""

temperature: float
Expand Down
7 changes: 4 additions & 3 deletions src/openai/types/audio/translation_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from ..._types import FileTypes
from ..audio_model import AudioModel
from ..audio_response_format import AudioResponseFormat

__all__ = ["TranslationCreateParams"]

Expand All @@ -33,10 +34,10 @@ class TranslationCreateParams(TypedDict, total=False):
should be in English.
"""

response_format: str
response_format: AudioResponseFormat
"""
The format of the transcript output, in one of these options: `json`, `text`,
`srt`, `verbose_json`, or `vtt`.
The format of the output, in one of these options: `json`, `text`, `srt`,
`verbose_json`, or `vtt`.
"""

temperature: float
Expand Down
7 changes: 7 additions & 0 deletions src/openai/types/audio_response_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing_extensions import Literal, TypeAlias

__all__ = ["AudioResponseFormat"]

AudioResponseFormat: TypeAlias = Literal["json", "text", "srt", "verbose_json", "vtt"]
8 changes: 4 additions & 4 deletions tests/api_resources/audio/test_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None:
translation = client.audio.translations.create(
file=b"raw file contents",
model="whisper-1",
prompt="string",
response_format="string",
prompt="prompt",
response_format="json",
temperature=0,
)
assert_matches_type(Translation, translation, path=["response"])
Expand Down Expand Up @@ -79,8 +79,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) ->
translation = await async_client.audio.translations.create(
file=b"raw file contents",
model="whisper-1",
prompt="string",
response_format="string",
prompt="prompt",
response_format="json",
temperature=0,
)
assert_matches_type(Translation, translation, path=["response"])
Expand Down
Loading