From 76abfe6fda3f0dfd85b2786cde8b5049b4012790 Mon Sep 17 00:00:00 2001 From: Alexander Petcoglo Date: Tue, 4 Mar 2025 14:52:43 +0100 Subject: [PATCH] updated chat types --- packages/sdk/package.json | 2 +- packages/sdk/src/chat/types.ts | 90 ++++++++++++++++++---------------- packages/toolkit/package.json | 2 +- 3 files changed, 51 insertions(+), 43 deletions(-) diff --git a/packages/sdk/package.json b/packages/sdk/package.json index b90b6c646f..bf507a1fe4 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "instill-sdk", - "version": "0.15.0-rc.12", + "version": "0.15.0-rc.13", "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 241929f37f..2c2865bd75 100644 --- a/packages/sdk/src/chat/types.ts +++ b/packages/sdk/src/chat/types.ts @@ -60,60 +60,68 @@ export type InstillChatEventCommonData = { createTime: string; }; -export type InstillChatEventStatusData = InstillChatEventCommonData & { - chatStatus: string; +export type InstillChatEventStatus = { + event: InstillChatTypeEnum.StatusUpdated; + data: InstillChatEventCommonData & { + chatStatus: string; + }; }; -export type InstillChatEventOutputData = InstillChatEventCommonData & { - outputChunkDelta: string; +export type InstillChatEventOutput = { + event: InstillChatTypeEnum.OutputUpdated; + data: InstillChatEventCommonData & { + outputChunkDelta: string; + }; }; -export type InstillChatEventNameData = InstillChatEventCommonData & { - name: string; +export type InstillChatEventName = { + event: InstillChatTypeEnum.NameUpdated; + data: InstillChatEventCommonData & { + name: string; + }; }; -export type InstillChatEventDebugData = InstillChatEventCommonData & { - debugOutput: string; +export type InstillChatEventDebug = { + event: InstillChatTypeEnum.DebugOutputUpdated; + data: InstillChatEventCommonData & { + debugOutput: string; + }; }; -export type InstillChatEventReplanData = InstillChatEventCommonData & { - numberOfReplan: number; +export type InstillChatEventReplan = { + event: InstillChatTypeEnum.ReplanTriggered; + data: InstillChatEventCommonData & { + numberOfReplan: number; + }; }; -export type InstillChatEventErrorData = InstillChatEventCommonData & { - errorType: InstillChatErrorType; - error: string; +export type InstillChatEventError = { + event: InstillChatTypeEnum.ErrorUpdated; + data: InstillChatEventCommonData & { + errorType: InstillChatErrorType; + error: string; + }; +}; + +export type InstillChatEventStart = { + event: InstillChatTypeEnum.Started; + data: InstillChatEventCommonData; +}; + +export type InstillChatEventEnd = { + event: InstillChatTypeEnum.Ended; + data: InstillChatEventCommonData; }; 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; - }; + | InstillChatEventStatus + | InstillChatEventOutput + | InstillChatEventName + | InstillChatEventDebug + | InstillChatEventReplan + | InstillChatEventError + | InstillChatEventStart + | InstillChatEventEnd; export type InstillChatFeed = InstillChatMessage[]; diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index 27eedd9072..e0ce0c3496 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@instill-ai/toolkit", - "version": "0.117.0-rc.5", + "version": "0.117.0-rc.8", "description": "Instill AI's frontend toolkit", "repository": "https://github.com/instill-ai/design-system.git", "bugs": "https://github.com/instill-ai/design-system/issues",