diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 5ed75d11b..da7db6479 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.52.0" + ".": "4.52.1" } diff --git a/.stats.yml b/.stats.yml index aa7e8427b..04682ea0a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 64 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8fe357c6b5a425d810d731e4102a052d8e38c5e2d66950e6de1025415160bf88.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-3a69e1cc9e1efda3fb82d0fb35961749f886a87594dae9d8d2aa5c60f157f5d2.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index f9c5d60a0..2288edfd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 4.52.1 (2024-06-25) + +Full Changelog: [v4.52.0...v4.52.1](https://github.com/openai/openai-node/compare/v4.52.0...v4.52.1) + +### Chores + +* **doc:** clarify service tier default value ([#908](https://github.com/openai/openai-node/issues/908)) ([e4c8100](https://github.com/openai/openai-node/commit/e4c8100c7732bdc336b52a48d09945782c0fa2a3)) +* **internal:** minor reformatting ([#911](https://github.com/openai/openai-node/issues/911)) ([78c9377](https://github.com/openai/openai-node/commit/78c9377fcd563645081629a89f3fda2c1ff4e175)) +* **internal:** re-order some imports ([#904](https://github.com/openai/openai-node/issues/904)) ([dbd5c40](https://github.com/openai/openai-node/commit/dbd5c4053ba2f255dfc56676ced5b30381843c75)) + ## 4.52.0 (2024-06-18) Full Changelog: [v4.51.0...v4.52.0](https://github.com/openai/openai-node/compare/v4.51.0...v4.52.0) diff --git a/README.md b/README.md index ebbb38293..04dc048a5 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ You can import in Deno via: ```ts -import OpenAI from 'https://deno.land/x/openai@v4.52.0/mod.ts'; +import OpenAI from 'https://deno.land/x/openai@v4.52.1/mod.ts'; ``` diff --git a/package.json b/package.json index c93d881cc..13c0b508b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openai", - "version": "4.52.0", + "version": "4.52.1", "description": "The official TypeScript library for the OpenAI API", "author": "OpenAI ", "types": "dist/index.d.ts", diff --git a/scripts/build-deno b/scripts/build-deno index c842fa5bc..ad438d13c 100755 --- a/scripts/build-deno +++ b/scripts/build-deno @@ -16,7 +16,7 @@ This is a build produced from https://github.com/openai/openai-node – please g Usage: \`\`\`ts -import OpenAI from "https://deno.land/x/openai@v4.52.0/mod.ts"; +import OpenAI from "https://deno.land/x/openai@v4.52.1/mod.ts"; const client = new OpenAI(); \`\`\` diff --git a/src/index.ts b/src/index.ts index fdafabf3d..ce455108e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from './core'; import * as Errors from './error'; -import { type Agent, type RequestInit } from './_shims/index'; import * as Uploads from './uploads'; +import { type Agent, type RequestInit } from './_shims/index'; +import * as Core from './core'; import * as Pagination from './pagination'; import * as API from './resources/index'; @@ -86,7 +86,9 @@ export interface ClientOptions { dangerouslyAllowBrowser?: boolean; } -/** API Client for interfacing with the OpenAI API. */ +/** + * API Client for interfacing with the OpenAI API. + */ export class OpenAI extends Core.APIClient { apiKey: string; organization: string | null; @@ -143,6 +145,7 @@ export class OpenAI extends Core.APIClient { maxRetries: options.maxRetries, fetch: options.fetch, }); + this._options = options; this.apiKey = apiKey; diff --git a/src/resources/audio/speech.ts b/src/resources/audio/speech.ts index bcfbc80cc..d0a6e7f31 100644 --- a/src/resources/audio/speech.ts +++ b/src/resources/audio/speech.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../core'; import { APIResource } from '../../resource'; -import { type Response } from '../../_shims/index'; +import * as Core from '../../core'; import * as SpeechAPI from './speech'; +import { type Response } from '../../_shims/index'; export class Speech extends APIResource { /** diff --git a/src/resources/audio/transcriptions.ts b/src/resources/audio/transcriptions.ts index bbffce4ed..0eb4e4b7c 100644 --- a/src/resources/audio/transcriptions.ts +++ b/src/resources/audio/transcriptions.ts @@ -1,16 +1,15 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../core'; import { APIResource } from '../../resource'; +import * as Core from '../../core'; import * as TranscriptionsAPI from './transcriptions'; -import { type Uploadable, multipartFormRequestOptions } from '../../core'; export class Transcriptions extends APIResource { /** * Transcribes audio into the input language. */ create(body: TranscriptionCreateParams, options?: Core.RequestOptions): Core.APIPromise { - return this._client.post('/audio/transcriptions', multipartFormRequestOptions({ body, ...options })); + return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options })); } } @@ -30,7 +29,7 @@ export interface TranscriptionCreateParams { * The audio file object (not file name) to transcribe, in one of these formats: * flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. */ - file: Uploadable; + file: Core.Uploadable; /** * ID of the model to use. Only `whisper-1` (which is powered by our open source diff --git a/src/resources/audio/translations.ts b/src/resources/audio/translations.ts index 890c59d55..48fddc2ee 100644 --- a/src/resources/audio/translations.ts +++ b/src/resources/audio/translations.ts @@ -1,16 +1,15 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../core'; import { APIResource } from '../../resource'; +import * as Core from '../../core'; import * as TranslationsAPI from './translations'; -import { type Uploadable, multipartFormRequestOptions } from '../../core'; export class Translations extends APIResource { /** * Translates audio into English. */ create(body: TranslationCreateParams, options?: Core.RequestOptions): Core.APIPromise { - return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options })); + return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options })); } } @@ -23,7 +22,7 @@ export interface TranslationCreateParams { * The audio file object (not file name) translate, in one of these formats: flac, * mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. */ - file: Uploadable; + file: Core.Uploadable; /** * ID of the model to use. Only `whisper-1` (which is powered by our open source diff --git a/src/resources/batches.ts b/src/resources/batches.ts index d23c059dc..738582f9e 100644 --- a/src/resources/batches.ts +++ b/src/resources/batches.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../core'; import { APIResource } from '../resource'; import { isRequestOptions } from '../core'; +import * as Core from '../core'; import * as BatchesAPI from './batches'; import { CursorPage, type CursorPageParams } from '../pagination'; diff --git a/src/resources/beta/assistants.ts b/src/resources/beta/assistants.ts index cdea09266..5d326a593 100644 --- a/src/resources/beta/assistants.ts +++ b/src/resources/beta/assistants.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../core'; import { APIResource } from '../../resource'; import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; import * as AssistantsAPI from './assistants'; import * as Shared from '../shared'; import * as MessagesAPI from './threads/messages'; diff --git a/src/resources/beta/threads/messages.ts b/src/resources/beta/threads/messages.ts index 07c5a573c..db58f45b8 100644 --- a/src/resources/beta/threads/messages.ts +++ b/src/resources/beta/threads/messages.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../core'; import { APIResource } from '../../../resource'; import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; import * as MessagesAPI from './messages'; import * as AssistantsAPI from '../assistants'; import { CursorPage, type CursorPageParams } from '../../../pagination'; diff --git a/src/resources/beta/threads/runs/runs.ts b/src/resources/beta/threads/runs/runs.ts index 0cc7e35d1..b4ed09cc2 100644 --- a/src/resources/beta/threads/runs/runs.ts +++ b/src/resources/beta/threads/runs/runs.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../../core'; -import { APIPromise } from '../../../../core'; import { APIResource } from '../../../../resource'; import { isRequestOptions } from '../../../../core'; +import { APIPromise } from '../../../../core'; +import * as Core from '../../../../core'; import { AssistantStream, RunCreateParamsBaseStream } from '../../../../lib/AssistantStream'; import { sleep } from '../../../../core'; import { RunSubmitToolOutputsParamsStream } from '../../../../lib/AssistantStream'; diff --git a/src/resources/beta/threads/runs/steps.ts b/src/resources/beta/threads/runs/steps.ts index 0cbb60ca4..09605d458 100644 --- a/src/resources/beta/threads/runs/steps.ts +++ b/src/resources/beta/threads/runs/steps.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../../core'; import { APIResource } from '../../../../resource'; import { isRequestOptions } from '../../../../core'; +import * as Core from '../../../../core'; import * as StepsAPI from './steps'; import { CursorPage, type CursorPageParams } from '../../../../pagination'; diff --git a/src/resources/beta/threads/threads.ts b/src/resources/beta/threads/threads.ts index 441bbe41c..aded9daf1 100644 --- a/src/resources/beta/threads/threads.ts +++ b/src/resources/beta/threads/threads.ts @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../core'; -import { APIPromise } from '../../../core'; import { APIResource } from '../../../resource'; import { isRequestOptions } from '../../../core'; import { AssistantStream, ThreadCreateAndRunParamsBaseStream } from '../../../lib/AssistantStream'; +import { APIPromise } from '../../../core'; +import * as Core from '../../../core'; import * as ThreadsAPI from './threads'; import * as AssistantsAPI from '../assistants'; import * as MessagesAPI from './messages'; diff --git a/src/resources/beta/vector-stores/file-batches.ts b/src/resources/beta/vector-stores/file-batches.ts index 2483e984f..890a92190 100644 --- a/src/resources/beta/vector-stores/file-batches.ts +++ b/src/resources/beta/vector-stores/file-batches.ts @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../core'; import { APIResource } from '../../../resource'; import { isRequestOptions } from '../../../core'; import { sleep } from '../../../core'; import { Uploadable } from '../../../core'; import { allSettledWithThrow } from '../../../lib/Util'; +import * as Core from '../../../core'; import * as FileBatchesAPI from './file-batches'; import * as FilesAPI from './files'; import { VectorStoreFilesPage } from './files'; diff --git a/src/resources/beta/vector-stores/files.ts b/src/resources/beta/vector-stores/files.ts index 04a0413be..594c51970 100644 --- a/src/resources/beta/vector-stores/files.ts +++ b/src/resources/beta/vector-stores/files.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../core'; import { APIResource } from '../../../resource'; -import { isRequestOptions } from '../../../core'; -import { sleep, Uploadable } from '../../../core'; +import { sleep, Uploadable, isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; import * as FilesAPI from './files'; import { CursorPage, type CursorPageParams } from '../../../pagination'; diff --git a/src/resources/beta/vector-stores/vector-stores.ts b/src/resources/beta/vector-stores/vector-stores.ts index d2d4c7d39..343f25953 100644 --- a/src/resources/beta/vector-stores/vector-stores.ts +++ b/src/resources/beta/vector-stores/vector-stores.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../core'; import { APIResource } from '../../../resource'; import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; import * as VectorStoresAPI from './vector-stores'; import * as FileBatchesAPI from './file-batches'; import * as FilesAPI from './files'; diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 664def2b2..44eb9520c 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../core'; -import { APIPromise } from '../../core'; import { APIResource } from '../../resource'; +import { APIPromise } from '../../core'; +import * as Core from '../../core'; import * as ChatCompletionsAPI from './completions'; import * as CompletionsAPI from '../completions'; import * as Shared from '../shared'; @@ -818,7 +818,8 @@ export interface ChatCompletionCreateParamsBase { * * - If set to 'auto', the system will utilize scale tier credits until they are * exhausted. - * - If set to 'default', the request will be processed in the shared cluster. + * - If set to 'default', the request will be processed using the default service + * tier with a lower uptime SLA and no latency guarentee. * * When this parameter is set, the response body will include the `service_tier` * utilized. diff --git a/src/resources/completions.ts b/src/resources/completions.ts index 26bf5ca0d..a6b527995 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../core'; -import { APIPromise } from '../core'; import { APIResource } from '../resource'; +import { APIPromise } from '../core'; +import * as Core from '../core'; import * as CompletionsAPI from './completions'; import * as ChatCompletionsAPI from './chat/completions'; import { Stream } from '../streaming'; diff --git a/src/resources/embeddings.ts b/src/resources/embeddings.ts index 28c954711..f72b9308a 100644 --- a/src/resources/embeddings.ts +++ b/src/resources/embeddings.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../core'; import { APIResource } from '../resource'; +import * as Core from '../core'; import * as EmbeddingsAPI from './embeddings'; export class Embeddings extends APIResource { diff --git a/src/resources/files.ts b/src/resources/files.ts index d86dd9972..a2d3aaa44 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -1,14 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../core'; import { APIResource } from '../resource'; import { isRequestOptions } from '../core'; -import { type Response } from '../_shims/index'; import { sleep } from '../core'; import { APIConnectionTimeoutError } from '../error'; +import * as Core from '../core'; import * as FilesAPI from './files'; -import { type Uploadable, multipartFormRequestOptions } from '../core'; import { Page } from '../pagination'; +import { type Response } from '../_shims/index'; export class Files extends APIResource { /** @@ -35,7 +34,7 @@ export class Files extends APIResource { * storage limits. */ create(body: FileCreateParams, options?: Core.RequestOptions): Core.APIPromise { - return this._client.post('/files', multipartFormRequestOptions({ body, ...options })); + return this._client.post('/files', Core.multipartFormRequestOptions({ body, ...options })); } /** @@ -188,7 +187,7 @@ export interface FileCreateParams { /** * The File object (not file name) to be uploaded. */ - file: Uploadable; + file: Core.Uploadable; /** * The intended purpose of the uploaded file. diff --git a/src/resources/fine-tuning/jobs/checkpoints.ts b/src/resources/fine-tuning/jobs/checkpoints.ts index 0e3cdeb79..02896b26d 100644 --- a/src/resources/fine-tuning/jobs/checkpoints.ts +++ b/src/resources/fine-tuning/jobs/checkpoints.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../core'; import { APIResource } from '../../../resource'; import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; import * as CheckpointsAPI from './checkpoints'; import { CursorPage, type CursorPageParams } from '../../../pagination'; diff --git a/src/resources/fine-tuning/jobs/jobs.ts b/src/resources/fine-tuning/jobs/jobs.ts index 12990c6fc..c4aae364a 100644 --- a/src/resources/fine-tuning/jobs/jobs.ts +++ b/src/resources/fine-tuning/jobs/jobs.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../../../core'; import { APIResource } from '../../../resource'; import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; import * as JobsAPI from './jobs'; import * as CheckpointsAPI from './checkpoints'; import { CursorPage, type CursorPageParams } from '../../../pagination'; diff --git a/src/resources/images.ts b/src/resources/images.ts index 337909578..24af635b2 100644 --- a/src/resources/images.ts +++ b/src/resources/images.ts @@ -1,9 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../core'; import { APIResource } from '../resource'; +import * as Core from '../core'; import * as ImagesAPI from './images'; -import { type Uploadable, multipartFormRequestOptions } from '../core'; export class Images extends APIResource { /** @@ -13,14 +12,14 @@ export class Images extends APIResource { body: ImageCreateVariationParams, options?: Core.RequestOptions, ): Core.APIPromise { - return this._client.post('/images/variations', multipartFormRequestOptions({ body, ...options })); + return this._client.post('/images/variations', Core.multipartFormRequestOptions({ body, ...options })); } /** * Creates an edited or extended image given an original image and a prompt. */ edit(body: ImageEditParams, options?: Core.RequestOptions): Core.APIPromise { - return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options })); + return this._client.post('/images/edits', Core.multipartFormRequestOptions({ body, ...options })); } /** @@ -64,7 +63,7 @@ export interface ImageCreateVariationParams { * The image to use as the basis for the variation(s). Must be a valid PNG file, * less than 4MB, and square. */ - image: Uploadable; + image: Core.Uploadable; /** * The model to use for image generation. Only `dall-e-2` is supported at this @@ -104,7 +103,7 @@ export interface ImageEditParams { * The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask * is not provided, image must have transparency, which will be used as the mask. */ - image: Uploadable; + image: Core.Uploadable; /** * A text description of the desired image(s). The maximum length is 1000 @@ -117,7 +116,7 @@ export interface ImageEditParams { * indicate where `image` should be edited. Must be a valid PNG file, less than * 4MB, and have the same dimensions as `image`. */ - mask?: Uploadable; + mask?: Core.Uploadable; /** * The model to use for image generation. Only `dall-e-2` is supported at this diff --git a/src/resources/models.ts b/src/resources/models.ts index 1d94c6c55..178915747 100644 --- a/src/resources/models.ts +++ b/src/resources/models.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../core'; import { APIResource } from '../resource'; +import * as Core from '../core'; import * as ModelsAPI from './models'; import { Page } from '../pagination'; diff --git a/src/resources/moderations.ts b/src/resources/moderations.ts index c018f65e7..86fbbc6b2 100644 --- a/src/resources/moderations.ts +++ b/src/resources/moderations.ts @@ -1,7 +1,7 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '../core'; import { APIResource } from '../resource'; +import * as Core from '../core'; import * as ModerationsAPI from './moderations'; export class Moderations extends APIResource { diff --git a/src/version.ts b/src/version.ts index 0f31a0778..77b6f5f83 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '4.52.0'; // x-release-please-version +export const VERSION = '4.52.1'; // x-release-please-version diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index 6db84d3fe..724743f30 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -1,8 +1,10 @@ -import { APIClient } from 'openai/core'; +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -const { stringifyQuery } = APIClient.prototype as any; +import { OpenAI } from 'openai'; -describe('APIClient.stringifyQuery', () => { +const { stringifyQuery } = OpenAI.prototype as any; + +describe(stringifyQuery, () => { for (const [input, expected] of [ [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], [{ a: null, b: false, c: undefined }, 'a=&b=false'], @@ -18,6 +20,7 @@ describe('APIClient.stringifyQuery', () => { expect(stringifyQuery(input)).toEqual(expected); }); } + for (const value of [[], {}, new Date()]) { it(`${JSON.stringify(value)} -> `, () => { expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`);