From 5893e37406ff85331c85a3baa519ca3051a28e00 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Fri, 8 Sep 2023 17:34:34 +0100 Subject: [PATCH] feat(types): extract ChatCompletionRole enum to its own type (#298) --- api.md | 1 + src/resources/chat/chat.ts | 1 + src/resources/chat/completions.ts | 10 ++++++++-- src/resources/chat/index.ts | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/api.md b/api.md index e26b57850..7285097f2 100644 --- a/api.md +++ b/api.md @@ -20,6 +20,7 @@ Types: - ChatCompletionChunk - ChatCompletionMessage - ChatCompletionMessageParam +- ChatCompletionRole - CreateChatCompletionRequestMessage Methods: diff --git a/src/resources/chat/chat.ts b/src/resources/chat/chat.ts index 5d10f2f4d..6ef43dd7a 100644 --- a/src/resources/chat/chat.ts +++ b/src/resources/chat/chat.ts @@ -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; diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 97ab2e9dd..dfc37a731 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -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 { @@ -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 @@ -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 */ @@ -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; diff --git a/src/resources/chat/index.ts b/src/resources/chat/index.ts index ea9d1d1b9..32dea91fe 100644 --- a/src/resources/chat/index.ts +++ b/src/resources/chat/index.ts @@ -6,6 +6,7 @@ export { ChatCompletionChunk, ChatCompletionMessage, ChatCompletionMessageParam, + ChatCompletionRole, CreateChatCompletionRequestMessage, ChatCompletionCreateParams, CompletionCreateParams,