Skip to content

Commit

Permalink
feat: extract chat models to a named enum (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Apr 16, 2024
1 parent bebf4f0 commit 141d2ed
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
4 changes: 4 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Methods:

# Chat

Types:

- <code><a href="./src/resources/chat/chat.ts">ChatModel</a></code>

## Completions

Types:
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export namespace OpenAI {
export import CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;

export import Chat = API.Chat;
export import ChatModel = API.ChatModel;
export import ChatCompletion = API.ChatCompletion;
export import ChatCompletionAssistantMessageParam = API.ChatCompletionAssistantMessageParam;
export import ChatCompletionChunk = API.ChatCompletionChunk;
Expand Down
23 changes: 23 additions & 0 deletions src/resources/chat/chat.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from 'openai/resource';
import * as ChatAPI from 'openai/resources/chat/chat';
import * as CompletionsAPI from 'openai/resources/chat/completions';

export class Chat extends APIResource {
completions: CompletionsAPI.Completions = new CompletionsAPI.Completions(this._client);
}

export type ChatModel =
| '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-0301'
| 'gpt-3.5-turbo-0613'
| 'gpt-3.5-turbo-1106'
| 'gpt-3.5-turbo-0125'
| 'gpt-3.5-turbo-16k-0613';

export namespace Chat {
export import ChatModel = ChatAPI.ChatModel;
export import Completions = CompletionsAPI.Completions;
export import ChatCompletion = CompletionsAPI.ChatCompletion;
export import ChatCompletionAssistantMessageParam = CompletionsAPI.ChatCompletionAssistantMessageParam;
Expand Down
23 changes: 2 additions & 21 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { APIResource } from 'openai/resource';
import * as ChatCompletionsAPI from 'openai/resources/chat/completions';
import * as CompletionsAPI from 'openai/resources/completions';
import * as Shared from 'openai/resources/shared';
import * as ChatAPI from 'openai/resources/chat/chat';
import { Stream } from 'openai/streaming';

export class Completions extends APIResource {
Expand Down Expand Up @@ -665,27 +666,7 @@ export interface ChatCompletionCreateParamsBase {
* [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility)
* table for details on which models work with the Chat API.
*/
model:
| (string & {})
| '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-0301'
| '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;

/**
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their
Expand Down
2 changes: 1 addition & 1 deletion src/resources/chat/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Chat } from './chat';
export {
ChatCompletion,
ChatCompletionAssistantMessageParam,
Expand Down Expand Up @@ -30,3 +29,4 @@ export {
CompletionCreateParamsStreaming,
Completions,
} from './completions';
export { ChatModel, Chat } from './chat';

0 comments on commit 141d2ed

Please sign in to comment.