Skip to content

Commit

Permalink
refactor: use type imports for type-only imports (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stainless Bot authored and stainless-app[bot] committed Nov 1, 2024
1 parent 622c80a commit 6421d69
Show file tree
Hide file tree
Showing 40 changed files with 1,307 additions and 884 deletions.
377 changes: 251 additions & 126 deletions src/index.ts

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/lib/AssistantStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Text,
ImageFile,
TextDelta,
Messages,
MessageDelta,
MessageContent,
} from 'openai/resources/beta/threads/messages';
import * as Core from 'openai/core';
Expand All @@ -31,7 +31,6 @@ import {
import { RunStep, RunStepDelta, ToolCall, ToolCallDelta } from 'openai/resources/beta/threads/runs/steps';
import { ThreadCreateAndRunParamsBase, Threads } from 'openai/resources/beta/threads/threads';
import { BaseEvents, EventStream } from './EventStream';
import MessageDelta = Messages.MessageDelta;

export interface AssistantStreamEvents extends BaseEvents {
run: (run: Run) => void;
Expand Down
70 changes: 43 additions & 27 deletions src/resources/audio/audio.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../resource';
import * as AudioAPI from './audio';
import * as SpeechAPI from './speech';
import { Speech, SpeechCreateParams, SpeechModel } from './speech';
import * as TranscriptionsAPI from './transcriptions';
import {
Transcription,
TranscriptionCreateParams,
TranscriptionCreateResponse,
TranscriptionSegment,
TranscriptionVerbose,
TranscriptionWord,
Transcriptions,
} from './transcriptions';
import * as TranslationsAPI from './translations';
import {
Translation,
TranslationCreateParams,
TranslationCreateResponse,
TranslationVerbose,
Translations,
} from './translations';

export class Audio extends APIResource {
transcriptions: TranscriptionsAPI.Transcriptions = new TranscriptionsAPI.Transcriptions(this._client);
Expand All @@ -20,30 +36,30 @@ export type AudioModel = 'whisper-1';
*/
export type AudioResponseFormat = 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';

export namespace Audio {
export import AudioModel = AudioAPI.AudioModel;
export import AudioResponseFormat = AudioAPI.AudioResponseFormat;
export import Transcriptions = TranscriptionsAPI.Transcriptions;
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionSegment = TranscriptionsAPI.TranscriptionSegment;
export import TranscriptionVerbose = TranscriptionsAPI.TranscriptionVerbose;
export import TranscriptionWord = TranscriptionsAPI.TranscriptionWord;
export import TranscriptionCreateResponse = TranscriptionsAPI.TranscriptionCreateResponse;
export type TranscriptionCreateParams<
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined =
| AudioAPI.AudioResponseFormat
| undefined,
> = TranscriptionsAPI.TranscriptionCreateParams<ResponseFormat>;
export import Translations = TranslationsAPI.Translations;
export import Translation = TranslationsAPI.Translation;
export import TranslationVerbose = TranslationsAPI.TranslationVerbose;
export import TranslationCreateResponse = TranslationsAPI.TranslationCreateResponse;
export type TranslationCreateParams<
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined =
| AudioAPI.AudioResponseFormat
| undefined,
> = TranslationsAPI.TranslationCreateParams<ResponseFormat>;
export import Speech = SpeechAPI.Speech;
export import SpeechModel = SpeechAPI.SpeechModel;
export import SpeechCreateParams = SpeechAPI.SpeechCreateParams;
Audio.Transcriptions = Transcriptions;
Audio.Translations = Translations;
Audio.Speech = Speech;

export declare namespace Audio {
export { type AudioModel as AudioModel, type AudioResponseFormat as AudioResponseFormat };

export {
Transcriptions as Transcriptions,
type Transcription as Transcription,
type TranscriptionSegment as TranscriptionSegment,
type TranscriptionVerbose as TranscriptionVerbose,
type TranscriptionWord as TranscriptionWord,
type TranscriptionCreateResponse as TranscriptionCreateResponse,
type TranscriptionCreateParams as TranscriptionCreateParams,
};

export {
Translations as Translations,
type Translation as Translation,
type TranslationVerbose as TranslationVerbose,
type TranslationCreateResponse as TranslationCreateResponse,
type TranslationCreateParams as TranslationCreateParams,
};

export { Speech as Speech, type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
}
24 changes: 12 additions & 12 deletions src/resources/audio/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { AudioModel, AudioResponseFormat, Audio } from './audio';
export { SpeechModel, SpeechCreateParams, Speech } from './speech';
export { Audio, type AudioModel, type AudioResponseFormat } from './audio';
export { Speech, type SpeechModel, type SpeechCreateParams } from './speech';
export {
Transcription,
TranscriptionSegment,
TranscriptionVerbose,
TranscriptionWord,
TranscriptionCreateResponse,
TranscriptionCreateParams,
Transcriptions,
type Transcription,
type TranscriptionSegment,
type TranscriptionVerbose,
type TranscriptionWord,
type TranscriptionCreateResponse,
type TranscriptionCreateParams,
} from './transcriptions';
export {
Translation,
TranslationVerbose,
TranslationCreateResponse,
TranslationCreateParams,
Translations,
type Translation,
type TranslationVerbose,
type TranslationCreateResponse,
type TranslationCreateParams,
} from './translations';
6 changes: 2 additions & 4 deletions src/resources/audio/speech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as SpeechAPI from './speech';
import { type Response } from '../../_shims/index';

export class Speech extends APIResource {
Expand Down Expand Up @@ -49,7 +48,6 @@ export interface SpeechCreateParams {
speed?: number;
}

export namespace Speech {
export import SpeechModel = SpeechAPI.SpeechModel;
export import SpeechCreateParams = SpeechAPI.SpeechCreateParams;
export declare namespace Speech {
export { type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
}
21 changes: 9 additions & 12 deletions src/resources/audio/transcriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as TranscriptionsAPI from './transcriptions';
import * as AudioAPI from './audio';

export class Transcriptions extends APIResource {
Expand Down Expand Up @@ -205,15 +204,13 @@ export interface TranscriptionCreateParams<
timestamp_granularities?: Array<'word' | 'segment'>;
}

export namespace Transcriptions {
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionSegment = TranscriptionsAPI.TranscriptionSegment;
export import TranscriptionVerbose = TranscriptionsAPI.TranscriptionVerbose;
export import TranscriptionWord = TranscriptionsAPI.TranscriptionWord;
export import TranscriptionCreateResponse = TranscriptionsAPI.TranscriptionCreateResponse;
export type TranscriptionCreateParams<
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined =
| AudioAPI.AudioResponseFormat
| undefined,
> = TranscriptionsAPI.TranscriptionCreateParams<ResponseFormat>;
export declare namespace Transcriptions {
export {
type Transcription as Transcription,
type TranscriptionSegment as TranscriptionSegment,
type TranscriptionVerbose as TranscriptionVerbose,
type TranscriptionWord as TranscriptionWord,
type TranscriptionCreateResponse as TranscriptionCreateResponse,
type TranscriptionCreateParams as TranscriptionCreateParams,
};
}
17 changes: 7 additions & 10 deletions src/resources/audio/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as TranslationsAPI from './translations';
import * as AudioAPI from './audio';
import * as TranscriptionsAPI from './transcriptions';

Expand Down Expand Up @@ -98,13 +97,11 @@ export interface TranslationCreateParams<
temperature?: number;
}

export namespace Translations {
export import Translation = TranslationsAPI.Translation;
export import TranslationVerbose = TranslationsAPI.TranslationVerbose;
export import TranslationCreateResponse = TranslationsAPI.TranslationCreateResponse;
export type TranslationCreateParams<
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined =
| AudioAPI.AudioResponseFormat
| undefined,
> = TranslationsAPI.TranslationCreateParams<ResponseFormat>;
export declare namespace Translations {
export {
type Translation as Translation,
type TranslationVerbose as TranslationVerbose,
type TranslationCreateResponse as TranslationCreateResponse,
type TranslationCreateParams as TranslationCreateParams,
};
}
18 changes: 11 additions & 7 deletions src/resources/batches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,15 @@ export interface BatchCreateParams {

export interface BatchListParams extends CursorPageParams {}

export namespace Batches {
export import Batch = BatchesAPI.Batch;
export import BatchError = BatchesAPI.BatchError;
export import BatchRequestCounts = BatchesAPI.BatchRequestCounts;
export import BatchesPage = BatchesAPI.BatchesPage;
export import BatchCreateParams = BatchesAPI.BatchCreateParams;
export import BatchListParams = BatchesAPI.BatchListParams;
Batches.BatchesPage = BatchesPage;

export declare namespace Batches {
export {
type Batch as Batch,
type BatchError as BatchError,
type BatchRequestCounts as BatchRequestCounts,
BatchesPage as BatchesPage,
type BatchCreateParams as BatchCreateParams,
type BatchListParams as BatchListParams,
};
}
37 changes: 20 additions & 17 deletions src/resources/beta/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
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 ChatAPI from '../chat/chat';
import * as MessagesAPI from './threads/messages';
Expand Down Expand Up @@ -1396,20 +1395,24 @@ export interface AssistantListParams extends CursorPageParams {
order?: 'asc' | 'desc';
}

export namespace Assistants {
export import Assistant = AssistantsAPI.Assistant;
export import AssistantDeleted = AssistantsAPI.AssistantDeleted;
export import AssistantStreamEvent = AssistantsAPI.AssistantStreamEvent;
export import AssistantTool = AssistantsAPI.AssistantTool;
export import CodeInterpreterTool = AssistantsAPI.CodeInterpreterTool;
export import FileSearchTool = AssistantsAPI.FileSearchTool;
export import FunctionTool = AssistantsAPI.FunctionTool;
export import MessageStreamEvent = AssistantsAPI.MessageStreamEvent;
export import RunStepStreamEvent = AssistantsAPI.RunStepStreamEvent;
export import RunStreamEvent = AssistantsAPI.RunStreamEvent;
export import ThreadStreamEvent = AssistantsAPI.ThreadStreamEvent;
export import AssistantsPage = AssistantsAPI.AssistantsPage;
export import AssistantCreateParams = AssistantsAPI.AssistantCreateParams;
export import AssistantUpdateParams = AssistantsAPI.AssistantUpdateParams;
export import AssistantListParams = AssistantsAPI.AssistantListParams;
Assistants.AssistantsPage = AssistantsPage;

export declare namespace Assistants {
export {
type Assistant as Assistant,
type AssistantDeleted as AssistantDeleted,
type AssistantStreamEvent as AssistantStreamEvent,
type AssistantTool as AssistantTool,
type CodeInterpreterTool as CodeInterpreterTool,
type FileSearchTool as FileSearchTool,
type FunctionTool as FunctionTool,
type MessageStreamEvent as MessageStreamEvent,
type RunStepStreamEvent as RunStepStreamEvent,
type RunStreamEvent as RunStreamEvent,
type ThreadStreamEvent as ThreadStreamEvent,
AssistantsPage as AssistantsPage,
type AssistantCreateParams as AssistantCreateParams,
type AssistantUpdateParams as AssistantUpdateParams,
type AssistantListParams as AssistantListParams,
};
}
Loading

0 comments on commit 6421d69

Please sign in to comment.