From d38f2c2648b6990f217c3c7d83ca31f3739641d3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:20:44 +0000 Subject: [PATCH 1/2] feat(api): update enum values, comments, and examples (#1280) --- .stats.yml | 2 +- src/resources/audio/speech.ts | 8 ++--- src/resources/beta/realtime/realtime.ts | 32 +++++++++++-------- src/resources/beta/realtime/sessions.ts | 30 ++++++++++------- src/resources/chat/completions.ts | 9 ++---- src/resources/embeddings.ts | 3 +- .../beta/realtime/sessions.test.ts | 27 ++-------------- tests/api-resources/chat/completions.test.ts | 2 +- tests/api-resources/completions.test.ts | 2 +- 9 files changed, 49 insertions(+), 66 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9600edae3..d518bac58 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 69 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-3904ef6b29a89c98f93a9b7da19879695f3c440564be6384db7af1b734611ede.yml diff --git a/src/resources/audio/speech.ts b/src/resources/audio/speech.ts index bd2ed9f65..35e82c4c1 100644 --- a/src/resources/audio/speech.ts +++ b/src/resources/audio/speech.ts @@ -33,12 +33,12 @@ export interface SpeechCreateParams { model: (string & {}) | SpeechModel; /** - * The voice to use when generating the audio. Supported voices are `alloy`, - * `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are - * available in the + * The voice to use when generating the audio. Supported voices are `alloy`, `ash`, + * `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the + * voices are available in the * [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options). */ - voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer'; + voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer'; /** * The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, diff --git a/src/resources/beta/realtime/realtime.ts b/src/resources/beta/realtime/realtime.ts index 5de06917a..0fb66eb49 100644 --- a/src/resources/beta/realtime/realtime.ts +++ b/src/resources/beta/realtime/realtime.ts @@ -173,9 +173,10 @@ export interface ConversationItemCreateEvent { /** * The ID of the preceding item after which the new item will be inserted. If not - * set, the new item will be appended to the end of the conversation. If set, it - * allows an item to be inserted mid-conversation. If the ID cannot be found, an - * error will be returned and the item will not be added. + * set, the new item will be appended to the end of the conversation. If set to + * `root`, the new item will be added to the beginning of the conversation. If set + * to an existing ID, it allows an item to be inserted mid-conversation. If the ID + * cannot be found, an error will be returned and the item will not be added. */ previous_item_id?: string; } @@ -1705,17 +1706,9 @@ export namespace SessionUpdateEvent { */ export interface Session { /** - * The Realtime model used for this session. - */ - model: - | 'gpt-4o-realtime-preview' - | 'gpt-4o-realtime-preview-2024-10-01' - | 'gpt-4o-realtime-preview-2024-12-17' - | 'gpt-4o-mini-realtime-preview' - | 'gpt-4o-mini-realtime-preview-2024-12-17'; - - /** - * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For + * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel + * (mono), and little-endian byte order. */ input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw'; @@ -1756,8 +1749,19 @@ export namespace SessionUpdateEvent { */ modalities?: Array<'text' | 'audio'>; + /** + * The Realtime model used for this session. + */ + model?: + | 'gpt-4o-realtime-preview' + | 'gpt-4o-realtime-preview-2024-10-01' + | 'gpt-4o-realtime-preview-2024-12-17' + | 'gpt-4o-mini-realtime-preview' + | 'gpt-4o-mini-realtime-preview-2024-12-17'; + /** * The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + * For `pcm16`, output audio is sampled at a rate of 24kHz. */ output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw'; diff --git a/src/resources/beta/realtime/sessions.ts b/src/resources/beta/realtime/sessions.ts index c1082d236..68c48db59 100644 --- a/src/resources/beta/realtime/sessions.ts +++ b/src/resources/beta/realtime/sessions.ts @@ -32,7 +32,9 @@ export interface Session { id?: string; /** - * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For + * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel + * (mono), and little-endian byte order. */ input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw'; @@ -86,6 +88,7 @@ export interface Session { /** * The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + * For `pcm16`, output audio is sampled at a rate of 24kHz. */ output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw'; @@ -372,17 +375,9 @@ export namespace SessionCreateResponse { export interface SessionCreateParams { /** - * The Realtime model used for this session. - */ - model: - | 'gpt-4o-realtime-preview' - | 'gpt-4o-realtime-preview-2024-10-01' - | 'gpt-4o-realtime-preview-2024-12-17' - | 'gpt-4o-mini-realtime-preview' - | 'gpt-4o-mini-realtime-preview-2024-12-17'; - - /** - * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + * The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For + * `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel + * (mono), and little-endian byte order. */ input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw'; @@ -423,8 +418,19 @@ export interface SessionCreateParams { */ modalities?: Array<'text' | 'audio'>; + /** + * The Realtime model used for this session. + */ + model?: + | 'gpt-4o-realtime-preview' + | 'gpt-4o-realtime-preview-2024-10-01' + | 'gpt-4o-realtime-preview-2024-12-17' + | 'gpt-4o-mini-realtime-preview' + | 'gpt-4o-mini-realtime-preview-2024-12-17'; + /** * The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. + * For `pcm16`, output audio is sampled at a rate of 24kHz. */ output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw'; diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 88c778036..683eb5ed4 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -76,8 +76,7 @@ export interface ChatCompletion { object: 'chat.completion'; /** - * The service tier used for processing the request. This field is only included if - * the `service_tier` parameter is specified in the request. + * The service tier used for processing the request. */ service_tier?: 'scale' | 'default' | null; @@ -300,8 +299,7 @@ export interface ChatCompletionChunk { object: 'chat.completion.chunk'; /** - * The service tier used for processing the request. This field is only included if - * the `service_tier` parameter is specified in the request. + * The service tier used for processing the request. */ service_tier?: 'scale' | 'default' | null; @@ -1115,9 +1113,6 @@ export interface ChatCompletionCreateParamsBase { * - If set to 'default', the request will be processed using the default service * tier with a lower uptime SLA and no latency guarentee. * - When not set, the default behavior is 'auto'. - * - * When this parameter is set, the response body will include the `service_tier` - * utilized. */ service_tier?: 'auto' | 'default' | null; diff --git a/src/resources/embeddings.ts b/src/resources/embeddings.ts index 4b1644a68..d01ffc807 100644 --- a/src/resources/embeddings.ts +++ b/src/resources/embeddings.ts @@ -86,7 +86,8 @@ export interface EmbeddingCreateParams { * `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 * dimensions or less. * [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) - * for counting tokens. + * for counting tokens. Some models may also impose a limit on total number of + * tokens summed across inputs. */ input: string | Array | Array | Array>; diff --git a/tests/api-resources/beta/realtime/sessions.test.ts b/tests/api-resources/beta/realtime/sessions.test.ts index 0ed998c27..dbb92ead3 100644 --- a/tests/api-resources/beta/realtime/sessions.test.ts +++ b/tests/api-resources/beta/realtime/sessions.test.ts @@ -9,8 +9,8 @@ const client = new OpenAI({ }); describe('resource sessions', () => { - test('create: only required params', async () => { - const responsePromise = client.beta.realtime.sessions.create({ model: 'gpt-4o-realtime-preview' }); + test('create', async () => { + const responsePromise = client.beta.realtime.sessions.create({}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -19,27 +19,4 @@ describe('resource sessions', () => { expect(dataAndResponse.data).toBe(response); expect(dataAndResponse.response).toBe(rawResponse); }); - - test('create: required and optional params', async () => { - const response = await client.beta.realtime.sessions.create({ - model: 'gpt-4o-realtime-preview', - input_audio_format: 'pcm16', - input_audio_transcription: { model: 'model' }, - instructions: 'instructions', - max_response_output_tokens: 0, - modalities: ['text'], - output_audio_format: 'pcm16', - temperature: 0, - tool_choice: 'tool_choice', - tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }], - turn_detection: { - create_response: true, - prefix_padding_ms: 0, - silence_duration_ms: 0, - threshold: 0, - type: 'type', - }, - voice: 'alloy', - }); - }); }); diff --git a/tests/api-resources/chat/completions.test.ts b/tests/api-resources/chat/completions.test.ts index dfc09f69b..8f1bc7d4c 100644 --- a/tests/api-resources/chat/completions.test.ts +++ b/tests/api-resources/chat/completions.test.ts @@ -43,7 +43,7 @@ describe('resource completions', () => { presence_penalty: -2, reasoning_effort: 'low', response_format: { type: 'text' }, - seed: -9007199254740991, + seed: 0, service_tier: 'auto', stop: 'string', store: true, diff --git a/tests/api-resources/completions.test.ts b/tests/api-resources/completions.test.ts index 82322dc3a..c98501a87 100644 --- a/tests/api-resources/completions.test.ts +++ b/tests/api-resources/completions.test.ts @@ -32,7 +32,7 @@ describe('resource completions', () => { max_tokens: 16, n: 1, presence_penalty: -2, - seed: -9007199254740991, + seed: 0, stop: '\n', stream: false, stream_options: { include_usage: true }, From 0a6600a9327d3e86df4efb59963c14ca388edaf6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:21:16 +0000 Subject: [PATCH 2/2] release: 4.80.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ jsr.json | 2 +- package.json | 2 +- src/version.ts | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b1ab5c7b9..a21d67d78 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.79.4" + ".": "4.80.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4254a9b8f..9126bf6a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 4.80.0 (2025-01-22) + +Full Changelog: [v4.79.4...v4.80.0](https://github.com/openai/openai-node/compare/v4.79.4...v4.80.0) + +### Features + +* **api:** update enum values, comments, and examples ([#1280](https://github.com/openai/openai-node/issues/1280)) ([d38f2c2](https://github.com/openai/openai-node/commit/d38f2c2648b6990f217c3c7d83ca31f3739641d3)) + ## 4.79.4 (2025-01-21) Full Changelog: [v4.79.3...v4.79.4](https://github.com/openai/openai-node/compare/v4.79.3...v4.79.4) diff --git a/jsr.json b/jsr.json index e6d772116..d79b07c2f 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@openai/openai", - "version": "4.79.4", + "version": "4.80.0", "exports": { ".": "./index.ts", "./helpers/zod": "./helpers/zod.ts", diff --git a/package.json b/package.json index d7a5555e5..fd85ffdd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "4.79.4", + "version": "4.80.0", "description": "The official TypeScript library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/src/version.ts b/src/version.ts index e8b9601ed..c9b6787c2 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.79.4'; // x-release-please-version +export const VERSION = '4.80.0'; // x-release-please-version