Skip to content

Commit

Permalink
updated chat types
Browse files Browse the repository at this point in the history
  • Loading branch information
orangecoloured committed Mar 4, 2025
1 parent da9eabe commit f2418b5
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
77 changes: 70 additions & 7 deletions packages/sdk/src/chat/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit f2418b5

Please sign in to comment.