Skip to content

Commit

Permalink
chore(internal): minor reformatting (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stainless Bot committed Jun 25, 2024
1 parent e4c8100 commit 78c9377
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 48 deletions.
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -143,6 +145,7 @@ export class OpenAI extends Core.APIClient {
maxRetries: options.maxRetries,
fetch: options.fetch,
});

this._options = options;

this.apiKey = apiKey;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/audio/speech.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
7 changes: 3 additions & 4 deletions src/resources/audio/transcriptions.ts
Original file line number Diff line number Diff line change
@@ -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<Transcription> {
return this._client.post('/audio/transcriptions', multipartFormRequestOptions({ body, ...options }));
return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
}
}

Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/resources/audio/translations.ts
Original file line number Diff line number Diff line change
@@ -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<Translation> {
return this._client.post('/audio/translations', multipartFormRequestOptions({ body, ...options }));
return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
}
}

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/resources/batches.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/assistants.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/threads/messages.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/threads/runs/steps.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 2 additions & 2 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/vector-stores/file-batches.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
5 changes: 2 additions & 3 deletions src/resources/beta/vector-stores/files.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/resources/beta/vector-stores/vector-stores.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions src/resources/completions.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/resources/embeddings.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions src/resources/files.ts
Original file line number Diff line number Diff line change
@@ -1,12 +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 { 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';

Expand Down Expand Up @@ -35,7 +34,7 @@ export class Files extends APIResource {
* storage limits.
*/
create(body: FileCreateParams, options?: Core.RequestOptions): Core.APIPromise<FileObject> {
return this._client.post('/files', multipartFormRequestOptions({ body, ...options }));
return this._client.post('/files', Core.multipartFormRequestOptions({ body, ...options }));
}

/**
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/resources/fine-tuning/jobs/checkpoints.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/resources/fine-tuning/jobs/jobs.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
13 changes: 6 additions & 7 deletions src/resources/images.ts
Original file line number Diff line number Diff line change
@@ -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 {
/**
Expand All @@ -13,14 +12,14 @@ export class Images extends APIResource {
body: ImageCreateVariationParams,
options?: Core.RequestOptions,
): Core.APIPromise<ImagesResponse> {
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<ImagesResponse> {
return this._client.post('/images/edits', multipartFormRequestOptions({ body, ...options }));
return this._client.post('/images/edits', Core.multipartFormRequestOptions({ body, ...options }));
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/resources/models.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/resources/moderations.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions tests/stringifyQuery.test.ts
Original file line number Diff line number Diff line change
@@ -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'],
Expand All @@ -18,6 +20,7 @@ describe('APIClient.stringifyQuery', () => {
expect(stringifyQuery(input)).toEqual(expected);
});
}

for (const value of [[], {}, new Date()]) {
it(`${JSON.stringify(value)} -> <error>`, () => {
expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`);
Expand Down

0 comments on commit 78c9377

Please sign in to comment.