Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extract out ImageModel, AudioModel, SpeechModel #964

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Methods:
Types:

- <code><a href="./src/resources/images.ts">Image</a></code>
- <code><a href="./src/resources/images.ts">ImageModel</a></code>
- <code><a href="./src/resources/images.ts">ImagesResponse</a></code>

Methods:
Expand All @@ -97,6 +98,10 @@ Methods:

# Audio

Types:

- <code><a href="./src/resources/audio/audio.ts">AudioModel</a></code>

## Transcriptions

Types:
Expand All @@ -119,6 +124,10 @@ Methods:

## Speech

Types:

- <code><a href="./src/resources/audio/speech.ts">SpeechModel</a></code>

Methods:

- <code title="post /audio/speech">client.audio.speech.<a href="./src/resources/audio/speech.ts">create</a>({ ...params }) -> Response</code>
Expand All @@ -128,6 +137,7 @@ Methods:
Types:

- <code><a href="./src/resources/moderations.ts">Moderation</a></code>
- <code><a href="./src/resources/moderations.ts">ModerationModel</a></code>
- <code><a href="./src/resources/moderations.ts">ModerationCreateResponse</a></code>

Methods:
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,18 @@ export namespace OpenAI {

export import Images = API.Images;
export import Image = API.Image;
export import ImageModel = API.ImageModel;
export import ImagesResponse = API.ImagesResponse;
export import ImageCreateVariationParams = API.ImageCreateVariationParams;
export import ImageEditParams = API.ImageEditParams;
export import ImageGenerateParams = API.ImageGenerateParams;

export import Audio = API.Audio;
export import AudioModel = API.AudioModel;

export import Moderations = API.Moderations;
export import Moderation = API.Moderation;
export import ModerationModel = API.ModerationModel;
export import ModerationCreateResponse = API.ModerationCreateResponse;
export import ModerationCreateParams = API.ModerationCreateParams;

Expand Down
5 changes: 5 additions & 0 deletions src/resources/audio/audio.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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 * as TranscriptionsAPI from './transcriptions';
import * as TranslationsAPI from './translations';
Expand All @@ -11,13 +12,17 @@ export class Audio extends APIResource {
speech: SpeechAPI.Speech = new SpeechAPI.Speech(this._client);
}

export type AudioModel = 'whisper-1';

export namespace Audio {
export import AudioModel = AudioAPI.AudioModel;
export import Transcriptions = TranscriptionsAPI.Transcriptions;
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionCreateParams = TranscriptionsAPI.TranscriptionCreateParams;
export import Translations = TranslationsAPI.Translations;
export import Translation = TranslationsAPI.Translation;
export import TranslationCreateParams = TranslationsAPI.TranslationCreateParams;
export import Speech = SpeechAPI.Speech;
export import SpeechModel = SpeechAPI.SpeechModel;
export import SpeechCreateParams = SpeechAPI.SpeechCreateParams;
}
4 changes: 2 additions & 2 deletions src/resources/audio/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Audio } from './audio';
export { SpeechCreateParams, Speech } from './speech';
export { AudioModel, Audio } from './audio';
export { SpeechModel, SpeechCreateParams, Speech } from './speech';
export { Transcription, TranscriptionCreateParams, Transcriptions } from './transcriptions';
export { Translation, TranslationCreateParams, Translations } from './translations';
5 changes: 4 additions & 1 deletion src/resources/audio/speech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class Speech extends APIResource {
}
}

export type SpeechModel = 'tts-1' | 'tts-1-hd';

export interface SpeechCreateParams {
/**
* The text to generate audio for. The maximum length is 4096 characters.
Expand All @@ -24,7 +26,7 @@ export interface SpeechCreateParams {
* One of the available [TTS models](https://platform.openai.com/docs/models/tts):
* `tts-1` or `tts-1-hd`
*/
model: (string & {}) | 'tts-1' | 'tts-1-hd';
model: (string & {}) | SpeechModel;

/**
* The voice to use when generating the audio. Supported voices are `alloy`,
Expand All @@ -48,5 +50,6 @@ export interface SpeechCreateParams {
}

export namespace Speech {
export import SpeechModel = SpeechAPI.SpeechModel;
export import SpeechCreateParams = SpeechAPI.SpeechCreateParams;
}
3 changes: 2 additions & 1 deletion src/resources/audio/transcriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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 @@ -35,7 +36,7 @@ export interface TranscriptionCreateParams {
* ID of the model to use. Only `whisper-1` (which is powered by our open source
* Whisper V2 model) is currently available.
*/
model: (string & {}) | 'whisper-1';
model: (string & {}) | AudioAPI.AudioModel;

/**
* The language of the input audio. Supplying the input language in
Expand Down
3 changes: 2 additions & 1 deletion src/resources/audio/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as TranslationsAPI from './translations';
import * as AudioAPI from './audio';

export class Translations extends APIResource {
/**
Expand All @@ -28,7 +29,7 @@ export interface TranslationCreateParams {
* ID of the model to use. Only `whisper-1` (which is powered by our open source
* Whisper V2 model) is currently available.
*/
model: (string & {}) | 'whisper-1';
model: (string & {}) | AudioAPI.AudioModel;

/**
* An optional text to guide the model's style or continue a previous audio
Expand Down
26 changes: 2 additions & 24 deletions src/resources/beta/assistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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';
import * as ThreadsAPI from './threads/threads';
import * as RunsAPI from './threads/runs/runs';
Expand Down Expand Up @@ -1053,30 +1054,7 @@ export interface AssistantCreateParams {
* [Model overview](https://platform.openai.com/docs/models/overview) for
* descriptions of them.
*/
model:
| (string & {})
| 'gpt-4o'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-4-0125-preview'
| 'gpt-4-turbo-preview'
| 'gpt-4-1106-preview'
| 'gpt-4-vision-preview'
| 'gpt-4'
| 'gpt-4-0314'
| 'gpt-4-0613'
| 'gpt-4-32k'
| 'gpt-4-32k-0314'
| 'gpt-4-32k-0613'
| 'gpt-3.5-turbo'
| 'gpt-3.5-turbo-16k'
| 'gpt-3.5-turbo-0613'
| 'gpt-3.5-turbo-1106'
| 'gpt-3.5-turbo-0125'
| 'gpt-3.5-turbo-16k-0613';
model: (string & {}) | ChatAPI.ChatModel;

/**
* The description of the assistant. The maximum length is 512 characters.
Expand Down
27 changes: 2 additions & 25 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { APIPromise } from '../../../../core';
import * as Core from '../../../../core';
import * as RunsAPI from './runs';
import * as AssistantsAPI from '../../assistants';
import * as ChatAPI from '../../../chat/chat';
import * as MessagesAPI from '../messages';
import * as ThreadsAPI from '../threads';
import * as StepsAPI from './steps';
Expand Down Expand Up @@ -542,31 +543,7 @@ export interface RunCreateParamsBase {
* model associated with the assistant. If not, the model associated with the
* assistant will be used.
*/
model?:
| (string & {})
| 'gpt-4o'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-4-0125-preview'
| 'gpt-4-turbo-preview'
| 'gpt-4-1106-preview'
| 'gpt-4-vision-preview'
| 'gpt-4'
| 'gpt-4-0314'
| 'gpt-4-0613'
| 'gpt-4-32k'
| 'gpt-4-32k-0314'
| 'gpt-4-32k-0613'
| 'gpt-3.5-turbo'
| 'gpt-3.5-turbo-16k'
| 'gpt-3.5-turbo-0613'
| 'gpt-3.5-turbo-1106'
| 'gpt-3.5-turbo-0125'
| 'gpt-3.5-turbo-16k-0613'
| null;
model?: (string & {}) | ChatAPI.ChatModel | null;

/**
* Whether to enable
Expand Down
27 changes: 2 additions & 25 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { APIPromise } from '../../../core';
import * as Core from '../../../core';
import * as ThreadsAPI from './threads';
import * as AssistantsAPI from '../assistants';
import * as ChatAPI from '../../chat/chat';
import * as MessagesAPI from './messages';
import * as RunsAPI from './runs/runs';
import { Stream } from '../../../streaming';
Expand Down Expand Up @@ -521,31 +522,7 @@ export interface ThreadCreateAndRunParamsBase {
* model associated with the assistant. If not, the model associated with the
* assistant will be used.
*/
model?:
| (string & {})
| 'gpt-4o'
| 'gpt-4o-2024-05-13'
| 'gpt-4o-mini'
| 'gpt-4o-mini-2024-07-18'
| 'gpt-4-turbo'
| 'gpt-4-turbo-2024-04-09'
| 'gpt-4-0125-preview'
| 'gpt-4-turbo-preview'
| 'gpt-4-1106-preview'
| 'gpt-4-vision-preview'
| 'gpt-4'
| 'gpt-4-0314'
| 'gpt-4-0613'
| 'gpt-4-32k'
| 'gpt-4-32k-0314'
| 'gpt-4-32k-0613'
| 'gpt-3.5-turbo'
| 'gpt-3.5-turbo-16k'
| 'gpt-3.5-turbo-0613'
| 'gpt-3.5-turbo-1106'
| 'gpt-3.5-turbo-0125'
| 'gpt-3.5-turbo-16k-0613'
| null;
model?: (string & {}) | ChatAPI.ChatModel | null;

/**
* Whether to enable
Expand Down
9 changes: 6 additions & 3 deletions src/resources/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export interface Image {
url?: string;
}

export type ImageModel = 'dall-e-2' | 'dall-e-3';

export interface ImagesResponse {
created: number;

Expand All @@ -69,7 +71,7 @@ export interface ImageCreateVariationParams {
* The model to use for image generation. Only `dall-e-2` is supported at this
* time.
*/
model?: (string & {}) | 'dall-e-2' | null;
model?: (string & {}) | ImageModel | null;

/**
* The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
Expand Down Expand Up @@ -122,7 +124,7 @@ export interface ImageEditParams {
* The model to use for image generation. Only `dall-e-2` is supported at this
* time.
*/
model?: (string & {}) | 'dall-e-2' | null;
model?: (string & {}) | ImageModel | null;

/**
* The number of images to generate. Must be between 1 and 10.
Expand Down Expand Up @@ -160,7 +162,7 @@ export interface ImageGenerateParams {
/**
* The model to use for image generation.
*/
model?: (string & {}) | 'dall-e-2' | 'dall-e-3' | null;
model?: (string & {}) | ImageModel | null;

/**
* The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
Expand Down Expand Up @@ -207,6 +209,7 @@ export interface ImageGenerateParams {

export namespace Images {
export import Image = ImagesAPI.Image;
export import ImageModel = ImagesAPI.ImageModel;
export import ImagesResponse = ImagesAPI.ImagesResponse;
export import ImageCreateVariationParams = ImagesAPI.ImageCreateVariationParams;
export import ImageEditParams = ImagesAPI.ImageEditParams;
Expand Down
11 changes: 9 additions & 2 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export * from './chat/index';
export * from './shared';
export { Audio } from './audio/audio';
export { AudioModel, Audio } from './audio/audio';
export {
Batch,
BatchError,
Expand Down Expand Up @@ -35,12 +35,19 @@ export {
export { FineTuning } from './fine-tuning/fine-tuning';
export {
Image,
ImageModel,
ImagesResponse,
ImageCreateVariationParams,
ImageEditParams,
ImageGenerateParams,
Images,
} from './images';
export { Model, ModelDeleted, ModelsPage, Models } from './models';
export { Moderation, ModerationCreateResponse, ModerationCreateParams, Moderations } from './moderations';
export {
Moderation,
ModerationModel,
ModerationCreateResponse,
ModerationCreateParams,
Moderations,
} from './moderations';
export { Upload, UploadCreateParams, UploadCompleteParams, Uploads } from './uploads/uploads';
5 changes: 4 additions & 1 deletion src/resources/moderations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export namespace Moderation {
}
}

export type ModerationModel = 'text-moderation-latest' | 'text-moderation-stable';

/**
* Represents if a given text input is potentially harmful.
*/
Expand Down Expand Up @@ -204,11 +206,12 @@ export interface ModerationCreateParams {
* model. Accuracy of `text-moderation-stable` may be slightly lower than for
* `text-moderation-latest`.
*/
model?: (string & {}) | 'text-moderation-latest' | 'text-moderation-stable';
model?: (string & {}) | ModerationModel;
}

export namespace Moderations {
export import Moderation = ModerationsAPI.Moderation;
export import ModerationModel = ModerationsAPI.ModerationModel;
export import ModerationCreateResponse = ModerationsAPI.ModerationCreateResponse;
export import ModerationCreateParams = ModerationsAPI.ModerationCreateParams;
}