From 167d682128cf03fff81f4814d68f26f3cccd0707 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Tue, 25 Jun 2024 11:22:03 +0000 Subject: [PATCH] chore(internal): minor reformatting --- src/index.ts | 9 ++++++--- src/resources/audio/speech.ts | 2 +- src/resources/audio/transcriptions.ts | 7 +++---- src/resources/audio/translations.ts | 7 +++---- src/resources/batches.ts | 2 +- src/resources/beta/assistants.ts | 2 +- src/resources/beta/threads/messages.ts | 2 +- src/resources/beta/threads/runs/runs.ts | 4 ++-- src/resources/beta/threads/runs/steps.ts | 2 +- src/resources/beta/threads/threads.ts | 4 ++-- src/resources/beta/vector-stores/file-batches.ts | 2 +- src/resources/beta/vector-stores/files.ts | 2 +- src/resources/beta/vector-stores/vector-stores.ts | 2 +- src/resources/chat/completions.ts | 4 ++-- src/resources/completions.ts | 4 ++-- src/resources/embeddings.ts | 2 +- src/resources/files.ts | 7 +++---- src/resources/fine-tuning/jobs/checkpoints.ts | 2 +- src/resources/fine-tuning/jobs/jobs.ts | 2 +- src/resources/images.ts | 13 ++++++------- src/resources/models.ts | 2 +- src/resources/moderations.ts | 2 +- tests/stringifyQuery.test.ts | 9 ++++++--- 23 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3a89a1072..df4ca86d7 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 } from './_shims/index'; import * as Uploads from './uploads'; +import { type Agent } 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 0c6a97ab5..d0a6e7f31 100644 --- a/src/resources/audio/speech.ts +++ b/src/resources/audio/speech.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 SpeechAPI from './speech'; import { type Response } from '../../_shims/index'; 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 ac90147cc..052f14d1a 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 * as RunsAPI from './runs'; import * as AssistantsAPI from '../../assistants'; import * as MessagesAPI from '../messages'; 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 af07fc4eb..e8f746d9c 100644 --- a/src/resources/beta/threads/threads.ts +++ b/src/resources/beta/threads/threads.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 * 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 0c7f7566f..78c997929 100644 --- a/src/resources/beta/vector-stores/file-batches.ts +++ b/src/resources/beta/vector-stores/file-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 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 4e5551d8c..f67ffd8c7 100644 --- a/src/resources/beta/vector-stores/files.ts +++ b/src/resources/beta/vector-stores/files.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 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 b49cf1069..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'; 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 f5bd0d82c..e3bedfbef 100644 --- a/src/resources/files.ts +++ b/src/resources/files.ts @@ -1,10 +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 { isRequestOptions } from '../core'; +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'; @@ -33,7 +32,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 })); } /** @@ -160,7 +159,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/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}`);