Skip to content

Commit

Permalink
feat(types): extract ChatCompletionRole enum to its own type (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Sep 8, 2023
1 parent 331eb4e commit 5893e37
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Types:
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionChunk</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionMessage</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionMessageParam</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionRole</a></code>
- <code><a href="./src/resources/chat/completions.ts">CreateChatCompletionRequestMessage</a></code>

Methods:
Expand Down
1 change: 1 addition & 0 deletions src/resources/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export namespace Chat {
export import ChatCompletionChunk = API.ChatCompletionChunk;
export import ChatCompletionMessage = API.ChatCompletionMessage;
export import ChatCompletionMessageParam = API.ChatCompletionMessageParam;
export import ChatCompletionRole = API.ChatCompletionRole;
export import CreateChatCompletionRequestMessage = API.CreateChatCompletionRequestMessage;
export import ChatCompletionCreateParams = API.ChatCompletionCreateParams;
export import CompletionCreateParams = API.CompletionCreateParams;
Expand Down
10 changes: 8 additions & 2 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export namespace ChatCompletionChunk {
/**
* The role of the author of this message.
*/
role?: 'system' | 'user' | 'assistant' | 'function';
role?: ChatCompletionRole;
}

export namespace Delta {
Expand Down Expand Up @@ -202,7 +202,7 @@ export interface ChatCompletionMessage {
/**
* The role of the author of this message.
*/
role: 'system' | 'user' | 'assistant' | 'function';
role: ChatCompletionRole;

/**
* The name and arguments of a function that should be called, as generated by the
Expand Down Expand Up @@ -281,6 +281,11 @@ export namespace ChatCompletionMessageParam {
}
}

/**
* The role of the author of this message.
*/
export type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'function';

/**
* @deprecated ChatCompletionMessageParam should be used instead
*/
Expand Down Expand Up @@ -497,6 +502,7 @@ export namespace Completions {
export import ChatCompletionChunk = API.ChatCompletionChunk;
export import ChatCompletionMessage = API.ChatCompletionMessage;
export import ChatCompletionMessageParam = API.ChatCompletionMessageParam;
export import ChatCompletionRole = API.ChatCompletionRole;
export import CreateChatCompletionRequestMessage = API.CreateChatCompletionRequestMessage;
export import ChatCompletionCreateParams = API.ChatCompletionCreateParams;
export import CompletionCreateParams = API.CompletionCreateParams;
Expand Down
1 change: 1 addition & 0 deletions src/resources/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export {
ChatCompletionChunk,
ChatCompletionMessage,
ChatCompletionMessageParam,
ChatCompletionRole,
CreateChatCompletionRequestMessage,
ChatCompletionCreateParams,
CompletionCreateParams,
Expand Down

0 comments on commit 5893e37

Please sign in to comment.