Skip to content

Commit 9dfc744

Browse files
committed
feat: extract chat models to a named enum (#775)
1 parent be0dd9f commit 9dfc744

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Methods:
2020

2121
# Chat
2222

23+
Types:
24+
25+
- <code><a href="./src/resources/chat/chat.ts">ChatModel</a></code>
26+
2327
## Completions
2428

2529
Types:

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export namespace OpenAI {
238238
export import CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;
239239

240240
export import Chat = API.Chat;
241+
export import ChatModel = API.ChatModel;
241242
export import ChatCompletion = API.ChatCompletion;
242243
export import ChatCompletionAssistantMessageParam = API.ChatCompletionAssistantMessageParam;
243244
export import ChatCompletionChunk = API.ChatCompletionChunk;

src/resources/chat/chat.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import { APIResource } from 'openai/resource';
4+
import * as ChatAPI from 'openai/resources/chat/chat';
45
import * as CompletionsAPI from 'openai/resources/chat/completions';
56

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

11+
export type ChatModel =
12+
| 'gpt-4-turbo'
13+
| 'gpt-4-turbo-2024-04-09'
14+
| 'gpt-4-0125-preview'
15+
| 'gpt-4-turbo-preview'
16+
| 'gpt-4-1106-preview'
17+
| 'gpt-4-vision-preview'
18+
| 'gpt-4'
19+
| 'gpt-4-0314'
20+
| 'gpt-4-0613'
21+
| 'gpt-4-32k'
22+
| 'gpt-4-32k-0314'
23+
| 'gpt-4-32k-0613'
24+
| 'gpt-3.5-turbo'
25+
| 'gpt-3.5-turbo-16k'
26+
| 'gpt-3.5-turbo-0301'
27+
| 'gpt-3.5-turbo-0613'
28+
| 'gpt-3.5-turbo-1106'
29+
| 'gpt-3.5-turbo-0125'
30+
| 'gpt-3.5-turbo-16k-0613';
31+
1032
export namespace Chat {
33+
export import ChatModel = ChatAPI.ChatModel;
1134
export import Completions = CompletionsAPI.Completions;
1235
export import ChatCompletion = CompletionsAPI.ChatCompletion;
1336
export import ChatCompletionAssistantMessageParam = CompletionsAPI.ChatCompletionAssistantMessageParam;

src/resources/chat/completions.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { APIResource } from 'openai/resource';
66
import * as ChatCompletionsAPI from 'openai/resources/chat/completions';
77
import * as CompletionsAPI from 'openai/resources/completions';
88
import * as Shared from 'openai/resources/shared';
9+
import * as ChatAPI from 'openai/resources/chat/chat';
910
import { Stream } from 'openai/streaming';
1011

1112
export class Completions extends APIResource {
@@ -665,27 +666,7 @@ export interface ChatCompletionCreateParamsBase {
665666
* [model endpoint compatibility](https://platform.openai.com/docs/models/model-endpoint-compatibility)
666667
* table for details on which models work with the Chat API.
667668
*/
668-
model:
669-
| (string & {})
670-
| 'gpt-4-turbo'
671-
| 'gpt-4-turbo-2024-04-09'
672-
| 'gpt-4-0125-preview'
673-
| 'gpt-4-turbo-preview'
674-
| 'gpt-4-1106-preview'
675-
| 'gpt-4-vision-preview'
676-
| 'gpt-4'
677-
| 'gpt-4-0314'
678-
| 'gpt-4-0613'
679-
| 'gpt-4-32k'
680-
| 'gpt-4-32k-0314'
681-
| 'gpt-4-32k-0613'
682-
| 'gpt-3.5-turbo'
683-
| 'gpt-3.5-turbo-16k'
684-
| 'gpt-3.5-turbo-0301'
685-
| 'gpt-3.5-turbo-0613'
686-
| 'gpt-3.5-turbo-1106'
687-
| 'gpt-3.5-turbo-0125'
688-
| 'gpt-3.5-turbo-16k-0613';
669+
model: (string & {}) | ChatAPI.ChatModel;
689670

690671
/**
691672
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their

src/resources/chat/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
export { Chat } from './chat';
43
export {
54
ChatCompletion,
65
ChatCompletionAssistantMessageParam,
@@ -30,3 +29,4 @@ export {
3029
CompletionCreateParamsStreaming,
3130
Completions,
3231
} from './completions';
32+
export { ChatModel, Chat } from './chat';

0 commit comments

Comments
 (0)