diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 470d9907fa..b90b6c646f 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "instill-sdk", - "version": "0.15.0-rc.7", + "version": "0.15.0-rc.12", "description": "Instill AI's Typescript SDK", "repository": "https://github.com/instill-ai/typescript-sdk.git", "bugs": "https://github.com/instill-ai/community/issues", diff --git a/packages/sdk/src/chat/types.ts b/packages/sdk/src/chat/types.ts index e84f5c6b6f..241929f37f 100644 --- a/packages/sdk/src/chat/types.ts +++ b/packages/sdk/src/chat/types.ts @@ -36,22 +36,85 @@ enum InstillChatTypeEnum { StatusUpdated = "CHAT_STATUS_UPDATED", OutputUpdated = "CHAT_OUTPUT_UPDATED", Ended = "CHAT_ENDED", - UserMessage = "CHAT_USER_MESSAGE", + NameUpdated = "CHAT_NAME_UPDATED", + DebugOutputUpdated = "CHAT_DEBUG_OUTPUT_UPDATED", + ReplanTriggered = "CHAT_REPLAN_TRIGGERED", + ErrorUpdated = "CHAT_ERROR_UPDATED", } export type InstillChatType = `${InstillChatTypeEnum}`; -export type InstillChatMessageData = { +enum InstillChatErrorTypeEnum { + Unknown = "UnknownError", + Internal = "InternalError", + ReplanLimit = "ReplanLimitError", + CreditInsufficient = "CreditInsufficientError", + RefusalLLM = "RefusalLLMError", + InvalidLLM = "InvalidLLMError", + UnavailableLLM = "UnavailableLLMError", +} + +export type InstillChatErrorType = `${InstillChatErrorTypeEnum}`; + +export type InstillChatEventCommonData = { createTime: string; - chatStatus?: string; - outputChunkDelta?: string; }; -export type InstillChatEvent = { - event: `${InstillChatTypeEnum}`; - data: InstillChatMessageData; +export type InstillChatEventStatusData = InstillChatEventCommonData & { + chatStatus: string; +}; + +export type InstillChatEventOutputData = InstillChatEventCommonData & { + outputChunkDelta: string; +}; + +export type InstillChatEventNameData = InstillChatEventCommonData & { + name: string; }; +export type InstillChatEventDebugData = InstillChatEventCommonData & { + debugOutput: string; +}; + +export type InstillChatEventReplanData = InstillChatEventCommonData & { + numberOfReplan: number; +}; + +export type InstillChatEventErrorData = InstillChatEventCommonData & { + errorType: InstillChatErrorType; + error: string; +}; + +export type InstillChatEvent = + | { + event: InstillChatTypeEnum.Started | InstillChatTypeEnum.Ended; + data: InstillChatEventCommonData; + } + | { + event: InstillChatTypeEnum.StatusUpdated; + data: InstillChatEventStatusData; + } + | { + event: InstillChatTypeEnum.OutputUpdated; + data: InstillChatEventOutputData; + } + | { + event: InstillChatTypeEnum.NameUpdated; + data: InstillChatEventNameData; + } + | { + event: InstillChatTypeEnum.DebugOutputUpdated; + data: InstillChatEventDebugData; + } + | { + event: InstillChatTypeEnum.ReplanTriggered; + data: InstillChatEventReplanData; + } + | { + event: InstillChatTypeEnum.ErrorUpdated; + data: InstillChatEventErrorData; + }; + export type InstillChatFeed = InstillChatMessage[]; export type ListPaginatedInstillChatsRequest = {