From 1ecf8f6b12323ed09fb6a2815c85b9533ee52a50 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Tue, 6 Feb 2024 01:09:45 +0000 Subject: [PATCH] feat(api): add `timestamp_granularities`, add `gpt-3.5-turbo-0125` model (#1125) --- src/openai/resources/audio/transcriptions.py | 14 ++++++++++++- src/openai/resources/chat/completions.py | 20 +++++++++++++------ .../audio/transcription_create_params.py | 15 ++++++++++++-- .../types/chat/completion_create_params.py | 3 ++- .../audio/test_transcriptions.py | 2 ++ 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/openai/resources/audio/transcriptions.py b/src/openai/resources/audio/transcriptions.py index 2c167be39..275098ce8 100644 --- a/src/openai/resources/audio/transcriptions.py +++ b/src/openai/resources/audio/transcriptions.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Union, Mapping, cast +from typing import List, Union, Mapping, cast from typing_extensions import Literal import httpx @@ -39,6 +39,7 @@ def create( prompt: str | NotGiven = NOT_GIVEN, response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | 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. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -74,6 +75,10 @@ def create( [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. + timestamp_granularities: The timestamp granularities to populate for this transcription. Any of these + options: `word`, or `segment`. Note: There is no additional latency for segment + timestamps, but generating word timestamps incurs additional latency. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -90,6 +95,7 @@ def create( "prompt": prompt, "response_format": response_format, "temperature": temperature, + "timestamp_granularities": timestamp_granularities, } ) files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) @@ -127,6 +133,7 @@ async def create( prompt: str | NotGiven = NOT_GIVEN, response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | 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. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -162,6 +169,10 @@ async def create( [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. + timestamp_granularities: The timestamp granularities to populate for this transcription. Any of these + options: `word`, or `segment`. Note: There is no additional latency for segment + timestamps, but generating word timestamps incurs additional latency. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -178,6 +189,7 @@ async def create( "prompt": prompt, "response_format": response_format, "temperature": temperature, + "timestamp_granularities": timestamp_granularities, } ) files = extract_files(cast(Mapping[str, object], body), paths=[["file"]]) diff --git a/src/openai/resources/chat/completions.py b/src/openai/resources/chat/completions.py index 45521833a..edc243e10 100644 --- a/src/openai/resources/chat/completions.py +++ b/src/openai/resources/chat/completions.py @@ -61,6 +61,7 @@ def create( "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ], @@ -155,7 +156,7 @@ def create( response_format: An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and - `gpt-3.5-turbo-1106`. + all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. @@ -250,6 +251,7 @@ def create( "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ], @@ -351,7 +353,7 @@ def create( response_format: An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and - `gpt-3.5-turbo-1106`. + all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. @@ -439,6 +441,7 @@ def create( "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ], @@ -540,7 +543,7 @@ def create( response_format: An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and - `gpt-3.5-turbo-1106`. + all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. @@ -628,6 +631,7 @@ def create( "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ], @@ -724,6 +728,7 @@ async def create( "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ], @@ -818,7 +823,7 @@ async def create( response_format: An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and - `gpt-3.5-turbo-1106`. + all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. @@ -913,6 +918,7 @@ async def create( "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ], @@ -1014,7 +1020,7 @@ async def create( response_format: An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and - `gpt-3.5-turbo-1106`. + all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. @@ -1102,6 +1108,7 @@ async def create( "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ], @@ -1203,7 +1210,7 @@ async def create( response_format: An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and - `gpt-3.5-turbo-1106`. + all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. @@ -1291,6 +1298,7 @@ async def create( "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ], diff --git a/src/openai/types/audio/transcription_create_params.py b/src/openai/types/audio/transcription_create_params.py index 7bd70d7b4..2d0a218f3 100644 --- a/src/openai/types/audio/transcription_create_params.py +++ b/src/openai/types/audio/transcription_create_params.py @@ -2,10 +2,11 @@ from __future__ import annotations -from typing import Union -from typing_extensions import Literal, Required, TypedDict +from typing import List, Union +from typing_extensions import Literal, Required, Annotated, TypedDict from ..._types import FileTypes +from ..._utils import PropertyInfo __all__ = ["TranscriptionCreateParams"] @@ -50,3 +51,13 @@ class TranscriptionCreateParams(TypedDict, total=False): [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. """ + + timestamp_granularities: Annotated[ + List[Literal["word", "segment"]], PropertyInfo(alias="timestamp_granularities[]") + ] + """The timestamp granularities to populate for this transcription. + + Any of these options: `word`, or `segment`. Note: There is no additional latency + for segment timestamps, but generating word timestamps incurs additional + latency. + """ diff --git a/src/openai/types/chat/completion_create_params.py b/src/openai/types/chat/completion_create_params.py index 3ea14d82b..dbc49594f 100644 --- a/src/openai/types/chat/completion_create_params.py +++ b/src/openai/types/chat/completion_create_params.py @@ -47,6 +47,7 @@ class CompletionCreateParamsBase(TypedDict, total=False): "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613", ], ] @@ -137,7 +138,7 @@ class CompletionCreateParamsBase(TypedDict, total=False): Compatible with [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and - `gpt-3.5-turbo-1106`. + all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. diff --git a/tests/api_resources/audio/test_transcriptions.py b/tests/api_resources/audio/test_transcriptions.py index d957871ab..80e364b48 100644 --- a/tests/api_resources/audio/test_transcriptions.py +++ b/tests/api_resources/audio/test_transcriptions.py @@ -34,6 +34,7 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None: prompt="string", response_format="json", temperature=0, + timestamp_granularities=["word", "segment"], ) assert_matches_type(Transcription, transcription, path=["response"]) @@ -84,6 +85,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> prompt="string", response_format="json", temperature=0, + timestamp_granularities=["word", "segment"], ) assert_matches_type(Transcription, transcription, path=["response"])