Commit 474803d0 by Shucai Chen

fix: 删除78个与.ts冲突的旧版.d.ts类型声明文件

旧版fastgpt使用独立.d.ts定义类型,新版FastGPT-main已将类型定义在.ts中。两套并存导致TSC编译栈溢出(RangeError)。删除后编译恢复正常。
parent 91ea5278
import type { OutLinkChatAuthProps } from '../../support/permission/chat.d';
export type preUploadImgProps = OutLinkChatAuthProps & {
// expiredTime?: Date;
metadata?: Record<string, any>;
};
export type UploadImgProps = preUploadImgProps & {
base64Img: string;
};
export type UrlFetchParams = {
urlList: string[];
selector?: string;
};
export type UrlFetchResponse = {
url: string;
title: string;
content: string;
selector?: string;
}[];
export type MongoImageSchemaType = {
_id: string;
teamId: string;
binary: Buffer;
expiredTime?: Date;
metadata?: {
mime?: string; // image mime type.
relatedId?: string; // This id is associated with a set of images
};
};
import type { BucketNameEnum } from './constants';
export type FileTokenQuery = {
bucketName: `${BucketNameEnum}`;
teamId: string;
uid: string; // tmbId/ share uid/ teamChat uid
fileId: string;
customExpireMinutes?: number;
};
export type AuthFrequencyLimitProps = {
eventId: string;
maxAmount: number;
expiredTime: Date;
num?: number;
};
import type { TrackEnum } from './constants';
import { OAuthEnum } from '../../../support/user/constant';
import { AppTypeEnum } from '../../../core/app/constants';
export type PushTrackCommonType = {
uid: string;
teamId: string;
tmbId: string;
};
export type TrackSchemaType = {
event: TrackEnum;
createTime: Date;
uid?: string;
teamId?: string;
tmbId?: string;
data: Record<string, any>;
};
export type GetPathProps = {
sourceId?: ParentIdType;
type: 'current' | 'parent';
};
export type ParentTreePathItemType = {
parentId: string;
parentName: string;
};
export type ParentIdType = string | null | undefined;
export type GetResourceFolderListProps = {
parentId: ParentIdType;
};
export type GetResourceFolderListItemResponse = {
name: string;
id: string;
};
export type GetResourceListItemResponse = GetResourceFolderListItemResponse & {
avatar: string;
isFolder: boolean;
};
export type SecretValueType = {
value: string;
secret: string;
};
export type StoreSecretValueType = Record<string, SecretValueType>;
export type AuthGoogleTokenProps = { googleToken: string; remoteip?: string | null };
import type { SystemConfigsTypeEnum } from './constants';
export type SystemConfigsType = {
_id: string;
type: `${SystemConfigsTypeEnum}`;
value: Record<string, any>;
createTime: Date;
};
import type { SubPlanType } from '../../../support/wallet/sub/type';
import { StandSubPlanLevelMapType } from '../../../support/wallet/sub/type';
import type {
ChatModelItemType,
FunctionModelItemType,
LLMModelItemType,
EmbeddingModelItemType,
AudioSpeechModels,
STTModelType,
RerankModelItemType
} from '../../../core/ai/model.d';
import { SubTypeEnum } from '../../../support/wallet/sub/constants';
export type NavbarItemType = {
id: string;
name: string;
avatar: string;
url: string;
isActive: boolean;
};
export type ExternalProviderWorkflowVarType = {
name: string;
key: string;
intro: string;
isOpen: boolean;
url?: string;
};
/* fastgpt main */
export type FastGPTConfigFileType = {
feConfigs: FastGPTFeConfigsType;
systemEnv: SystemEnvType;
subPlans?: SubPlanType;
// Abandon
llmModels?: ChatModelItemType[];
vectorModels?: EmbeddingModelItemType[];
reRankModels?: RerankModelItemType[];
audioSpeechModels?: TTSModelType[];
whisperModel?: STTModelType;
};
export type FastGPTFeConfigsType = {
show_workorder?: boolean;
show_emptyChat?: boolean;
isPlus?: boolean;
hideChatCopyrightSetting?: boolean;
register_method?: ['email' | 'phone' | 'sync'];
login_method?: ['email' | 'phone']; // Attention: login method is diffrent with oauth
find_password_method?: ['email' | 'phone'];
bind_notification_method?: ['email' | 'phone'];
googleClientVerKey?: string;
mcpServerProxyEndpoint?: string;
chineseRedirectUrl?: string;
show_emptyChat?: boolean;
show_appStore?: boolean;
show_git?: boolean;
show_pay?: boolean;
show_openai_account?: boolean;
show_promotion?: boolean;
show_team_chat?: boolean;
show_compliance_copywriting?: boolean;
show_aiproxy?: boolean;
show_coupon?: boolean;
concatMd?: string;
show_dataset_feishu?: boolean;
show_dataset_yuque?: boolean;
show_publish_feishu?: boolean;
show_publish_dingtalk?: boolean;
show_publish_offiaccount?: boolean;
show_dataset_enhance?: boolean;
show_batch_eval?: boolean;
concatMd?: string;
docUrl?: string;
openAPIDocUrl?: string;
systemPluginCourseUrl?: string;
appTemplateCourse?: string;
customApiDomain?: string;
customSharePageDomain?: string;
systemTitle?: string;
scripts?: { [key: string]: string }[];
favicon?: string;
sso?: {
icon?: string;
title?: string;
url?: string;
autoLogin?: boolean;
};
oauth?: {
github?: string;
google?: string;
wechat?: string;
microsoft?: {
clientId?: string;
tenantId?: string;
customButton?: string;
};
};
limit?: {
exportDatasetLimitMinutes?: number;
websiteSyncLimitMinuted?: number;
};
uploadFileMaxAmount?: number;
uploadFileMaxSize?: number;
evalFileMaxLines?: number;
// Compute by systemEnv.customPdfParse
showCustomPdfParse?: boolean;
customPdfParsePrice?: number;
lafEnv?: string;
navbarItems?: NavbarItemType[];
externalProviderWorkflowVariables?: ExternalProviderWorkflowVarType[];
payConfig?: {
wx?: boolean;
alipay?: boolean;
bank?: boolean;
};
};
export type SystemEnvType = {
openapiPrefix?: string;
vectorMaxProcess: number;
qaMaxProcess: number;
vlmMaxProcess: number;
tokenWorkers: number; // token count max worker
hnswEfSearch: number;
hnswMaxScanTuples: number;
oneapiUrl?: string;
chatApiKey?: string;
customPdfParse?: customPdfParseType;
};
export type customPdfParseType = {
url?: string;
key?: string;
doc2xKey?: string;
price?: number;
};
export type LicenseDataType = {
startTime: string;
expiredTime: string;
company: string;
description?: string; // 描述
hosts?: string[]; // 管理端有效域名
maxUsers?: number; // 最大用户数,不填默认不上限
maxApps?: number; // 最大应用数,不填默认不上限
maxDatasets?: number; // 最大数据集数,不填默认不上限
functions: {
sso: boolean;
pay: boolean;
customTemplates: boolean;
datasetEnhance: boolean;
batchEval: boolean;
};
};
import type { ModelTypeEnum } from './model';
import type { ModelProviderIdType } from './provider';
type PriceType = {
charsPointsPrice?: number; // 1k chars=n points; 60s=n points;
// If inputPrice is set, the input-output charging scheme is adopted
inputPrice?: number; // 1k tokens=n points
outputPrice?: number; // 1k tokens=n points
};
type BaseModelItemType = {
provider: ModelProviderIdType;
model: string;
name: string;
avatar?: string; // model icon, from provider
isActive?: boolean;
isCustom?: boolean;
isDefault?: boolean;
isDefaultDatasetTextModel?: boolean;
isDefaultDatasetImageModel?: boolean;
// If has requestUrl, it will request the model directly
requestUrl?: string;
requestAuth?: string;
};
export type LLMModelItemType = PriceType &
BaseModelItemType & {
type: ModelTypeEnum.llm;
// Model params
maxContext: number;
maxResponse: number;
quoteMaxToken: number;
maxTemperature?: number;
showTopP?: boolean;
responseFormatList?: string[];
showStopSign?: boolean;
censor?: boolean;
vision?: boolean;
reasoning?: boolean;
// diff function model
datasetProcess?: boolean; // dataset
usedInClassify?: boolean; // classify
usedInExtractFields?: boolean; // extract fields
usedInToolCall?: boolean; // tool call
useInEvaluation?: boolean; // evaluation
functionCall: boolean;
toolChoice: boolean;
defaultSystemChatPrompt?: string;
defaultConfig?: Record<string, any>;
fieldMap?: Record<string, string>;
};
export type EmbeddingModelItemType = PriceType &
BaseModelItemType & {
type: ModelTypeEnum.embedding;
defaultToken: number; // split text default token
maxToken: number; // model max token
weight: number; // training weight
hidden?: boolean; // Disallow creation
normalization?: boolean; // normalization processing
defaultConfig?: Record<string, any>; // post request config
dbConfig?: Record<string, any>; // Custom parameters for storage
queryConfig?: Record<string, any>; // Custom parameters for query
};
export type RerankModelItemType = PriceType &
BaseModelItemType & {
type: ModelTypeEnum.rerank;
};
export type TTSModelType = PriceType &
BaseModelItemType & {
type: ModelTypeEnum.tts;
voices: { label: string; value: string }[];
};
export type STTModelType = PriceType &
BaseModelItemType & {
type: ModelTypeEnum.stt;
};
import type { RequireOnlyOne } from '../../common/type/utils';
import {
type UpdateClbPermissionProps,
UpdatePermissionBody
} from '../../support/permission/collaborator';
import { PermissionValueType } from '../../support/permission/type';
export type UpdateAppCollaboratorBody = UpdateClbPermissionProps & {
appId: string;
};
export type AppCollaboratorDeleteParams = {
appId: string;
} & RequireOnlyOne<{
tmbId: string;
groupId: string;
orgId: string;
}>;
import type { PaginationProps } from '@fastgpt/web/common/fetch/type';
export type listEvaluationsBody = PaginationProps<{
searchKey?: string;
}>;
export type listEvalItemsBody = PaginationProps<{
evalId: string;
}>;
export type retryEvalItemBody = {
evalItemId: string;
};
export type updateEvalItemBody = {
evalItemId: string;
question: string;
expectedResponse: string;
variables: Record<string, string>;
};
import type { EvaluationStatusEnum } from './constants';
export type EvaluationSchemaType = {
_id: string;
teamId: string;
tmbId: string;
evalModel: string;
appId: string;
usageId: string;
name: string;
createTime: Date;
finishTime?: Date;
score?: number;
errorMessage?: string;
};
export type EvalItemSchemaType = {
evalId: string;
question: string;
expectedResponse: string;
globalVariables?: Record<string, any>;
history?: string;
response?: string;
responseTime?: Date;
finishTime?: Date;
status: EvaluationStatusEnum;
retry: number;
errorMessage?: string;
accuracy?: number;
relevance?: number;
semanticAccuracy?: number;
score?: number;
};
export type evaluationType = Pick<
EvaluationSchemaType,
'name' | 'appId' | 'createTime' | 'finishTime' | 'evalModel' | 'errorMessage' | 'score'
> & {
_id: string;
executorAvatar: string;
executorName: string;
appAvatar: string;
appName: string;
completedCount: number;
errorCount: number;
totalCount: number;
};
export type listEvalItemsItem = EvalItemSchemaType & {
evalItemId: string;
};
import type { FlowNodeTemplateType, StoreNodeItemType } from '../workflow/type/node';
import type { AppTypeEnum } from './constants';
import { PermissionTypeEnum } from '../../support/permission/constant';
import type {
NodeInputKeyEnum,
VariableInputEnum,
WorkflowIOValueTypeEnum
} from '../workflow/constants';
import type { SelectedDatasetType } from '../workflow/type/io';
import type { DatasetSearchModeEnum } from '../dataset/constants';
import { TeamTagSchema as TeamTagsSchemaType } from '@fastgpt/global/support/user/team/type.d';
import type { StoreEdgeItemType } from '../workflow/type/edge';
import type { AppPermission } from '../../support/permission/app/controller';
import type { ParentIdType } from '../../common/parentFolder/type';
import { FlowNodeInputTypeEnum } from '../../core/workflow/node/constant';
import type { WorkflowTemplateBasicType } from '@fastgpt/global/core/workflow/type';
import type { SourceMemberType } from '../../support/user/type';
import type { JSONSchemaInputType } from './jsonschema';
export type AppSchema = {
_id: string;
parentId?: ParentIdType;
teamId: string;
tmbId: string;
type: AppTypeEnum;
version?: 'v1' | 'v2';
name: string;
avatar: string;
intro: string;
updateTime: Date;
modules: StoreNodeItemType[];
edges: StoreEdgeItemType[];
pluginData?: {
nodeVersion?: string;
pluginUniId?: string; // plugin unique id(plugin name)
apiSchemaStr?: string; // api schema string
customHeaders?: string;
};
// App system config
chatConfig: AppChatConfigType;
scheduledTriggerConfig?: AppScheduledTriggerConfigType | null;
scheduledTriggerNextTime?: Date;
inited?: boolean;
teamTags: string[];
inheritPermission?: boolean;
// abandon
defaultPermission?: number;
};
export type AppListItemType = {
_id: string;
tmbId: string;
name: string;
avatar: string;
intro: string;
type: AppTypeEnum;
updateTime: Date;
pluginData?: AppSchema['pluginData'];
permission: AppPermission;
inheritPermission?: boolean;
private?: boolean;
sourceMember: SourceMemberType;
hasInteractiveNode?: boolean;
};
export type AppDetailType = AppSchema & {
permission: AppPermission;
};
export type AppDatasetSearchParamsType = {
searchMode: `${DatasetSearchModeEnum}`;
limit?: number; // limit max tokens
similarity?: number;
embeddingWeight?: number; // embedding weight, fullText weight = 1 - embeddingWeight
usingReRank?: boolean;
rerankModel?: string;
rerankWeight?: number;
datasetSearchUsingExtensionQuery?: boolean;
datasetSearchExtensionModel?: string;
datasetSearchExtensionBg?: string;
};
export type AppSimpleEditFormType = {
// templateId: string;
aiSettings: {
[NodeInputKeyEnum.aiModel]: string;
[NodeInputKeyEnum.aiSystemPrompt]?: string | undefined;
[NodeInputKeyEnum.aiChatTemperature]?: number;
[NodeInputKeyEnum.aiChatMaxToken]?: number;
[NodeInputKeyEnum.aiChatIsResponseText]: boolean;
maxHistories: number;
[NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode
[NodeInputKeyEnum.aiChatTopP]?: number;
[NodeInputKeyEnum.aiChatStopSign]?: string;
[NodeInputKeyEnum.aiChatResponseFormat]?: string;
[NodeInputKeyEnum.aiChatJsonSchema]?: string;
};
dataset: {
datasets: SelectedDatasetType;
} & AppDatasetSearchParamsType;
selectedTools: FlowNodeTemplateType[];
chatConfig: AppChatConfigType;
};
export type McpToolConfigType = {
name: string;
description: string;
inputSchema: JSONSchemaInputType;
};
/* app chat config type */
export type AppChatConfigType = {
welcomeText?: string;
variables?: VariableItemType[];
autoExecute?: AppAutoExecuteConfigType;
questionGuide?: AppQGConfigType;
ttsConfig?: AppTTSConfigType;
whisperConfig?: AppWhisperConfigType;
scheduledTriggerConfig?: AppScheduledTriggerConfigType;
chatInputGuide?: ChatInputGuideConfigType;
fileSelectConfig?: AppFileSelectConfigType;
// plugin
instruction?: string;
};
export type SettingAIDataType = {
model: string;
temperature?: number;
maxToken?: number;
isResponseAnswerText?: boolean;
maxHistories?: number;
[NodeInputKeyEnum.aiChatVision]?: boolean; // Is open vision mode
[NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode
[NodeInputKeyEnum.aiChatTopP]?: number;
[NodeInputKeyEnum.aiChatStopSign]?: string;
[NodeInputKeyEnum.aiChatResponseFormat]?: string;
[NodeInputKeyEnum.aiChatJsonSchema]?: string;
};
// variable
export type VariableItemType = {
// id: string;
key: string;
label: string;
type: VariableInputEnum;
required: boolean;
description: string;
valueType?: WorkflowIOValueTypeEnum;
defaultValue?: any;
// input
maxLength?: number;
// numberInput
max?: number;
min?: number;
// select
list?: { label: string; value: string }[];
// @deprecated
enums?: { value: string; label: string }[];
};
// tts
export type AppTTSConfigType = {
type: 'none' | 'web' | 'model';
model?: string;
voice?: string;
speed?: number;
};
// whisper
export type AppWhisperConfigType = {
open: boolean;
autoSend: boolean;
autoTTSResponse: boolean;
};
// question guide
export type AppQGConfigType = {
open: boolean;
model?: string;
customPrompt?: string;
};
// question guide text
export type ChatInputGuideConfigType = {
open: boolean;
customUrl: string;
};
// interval timer
export type AppScheduledTriggerConfigType = {
cronString: string;
timezone: string;
defaultPrompt: string;
};
// auto execute
export type AppAutoExecuteConfigType = {
open: boolean;
defaultPrompt: string;
};
// File
export type AppFileSelectConfigType = {
canSelectFile: boolean;
customPdfParse?: boolean;
canSelectImg: boolean;
maxFiles: number;
};
export type SystemPluginListItemType = {
_id: string;
name: string;
avatar: string;
};
export type AppTemplateSchemaType = {
templateId: string;
name: string;
intro: string;
avatar: string;
tags: string[];
type: string;
author?: string;
isActive?: boolean;
userGuide?: {
type: 'markdown' | 'link';
content?: string;
link?: string;
};
isQuickTemplate?: boolean;
order?: number;
workflow: WorkflowTemplateBasicType;
};
export type TemplateTypeSchemaType = {
typeName: string;
typeId: string;
typeOrder: number;
};
export type ChatInputGuideSchemaType = {
_id: string;
appId: string;
text: string;
};
export type ChatSettingSchema = {
_id: string;
appId: string;
teamId: string;
slogan: string;
dialogTips: string;
homeTabTitle: string;
wideLogoUrl?: string;
squareLogoUrl?: string;
selectedTools: {
pluginId: string;
name: string;
avatar: string;
inputs?: Record<`${NodeInputKeyEnum}` | string, any>;
}[];
};
export type ChatSettingUpdateParams = {
slogan?: string;
dialogTips?: string;
homeTabTitle?: string;
wideLogoUrl?: string;
squareLogoUrl?: string;
selectedTools: {
pluginId: string;
inputs?: Record<`${NodeInputKeyEnum}` | string, any>;
}[];
};
import { ClassifyQuestionAgentItemType } from '../workflow/template/system/classifyQuestion/type';
import type { SearchDataResponseItemType } from '../dataset/type';
import type {
ChatFileTypeEnum,
ChatItemValueTypeEnum,
ChatRoleEnum,
ChatSourceEnum,
ChatStatusEnum
} from './constants';
import type { FlowNodeTypeEnum } from '../workflow/node/constant';
import type { NodeInputKeyEnum, NodeOutputKeyEnum } from '../workflow/constants';
import type { DispatchNodeResponseKeyEnum } from '../workflow/runtime/constants';
import type { AppSchema, VariableItemType } from '../app/type';
import { AppChatConfigType } from '../app/type';
import type { AppSchema as AppType } from '@fastgpt/global/core/app/type.d';
import { DatasetSearchModeEnum } from '../dataset/constants';
import type { DispatchNodeResponseType } from '../workflow/runtime/type.d';
import type { ChatBoxInputType } from '../../../../projects/app/src/components/core/chat/ChatContainer/ChatBox/type';
import type { WorkflowInteractiveResponseType } from '../workflow/template/system/interactive/type';
import type { FlowNodeInputItemType } from '../workflow/type/io';
import type { FlowNodeTemplateType } from '../workflow/type/node.d';
export type ChatSchemaType = {
_id: string;
chatId: string;
userId: string;
teamId: string;
tmbId: string;
appId: string;
createTime: Date;
updateTime: Date;
title: string;
customTitle: string;
top: boolean;
source: `${ChatSourceEnum}`;
sourceName?: string;
shareId?: string;
outLinkUid?: string;
variableList?: VariableItemType[];
welcomeText?: string;
variables: Record<string, any>;
pluginInputs?: FlowNodeInputItemType[];
metadata?: Record<string, any>;
};
export type ChatWithAppSchema = Omit<ChatSchemaType, 'appId'> & {
appId: AppSchema;
};
export type UserChatItemValueItemType = {
type: ChatItemValueTypeEnum.text | ChatItemValueTypeEnum.file;
text?: {
content: string;
};
file?: {
type: `${ChatFileTypeEnum}`;
name?: string;
url: string;
};
};
export type UserChatItemType = {
obj: ChatRoleEnum.Human;
value: UserChatItemValueItemType[];
hideInUI?: boolean;
};
export type SystemChatItemValueItemType = {
type: ChatItemValueTypeEnum.text;
text?: {
content: string;
};
};
export type SystemChatItemType = {
obj: ChatRoleEnum.System;
value: SystemChatItemValueItemType[];
};
export type AIChatItemValueItemType = {
type:
| ChatItemValueTypeEnum.text
| ChatItemValueTypeEnum.reasoning
| ChatItemValueTypeEnum.tool
| ChatItemValueTypeEnum.interactive;
text?: {
content: string;
};
reasoning?: {
content: string;
};
tools?: ToolModuleResponseItemType[];
interactive?: WorkflowInteractiveResponseType;
};
export type AIChatItemType = {
obj: ChatRoleEnum.AI;
value: AIChatItemValueItemType[];
memories?: Record<string, any>;
userGoodFeedback?: string;
userBadFeedback?: string;
customFeedbacks?: string[];
adminFeedback?: AdminFbkType;
[DispatchNodeResponseKeyEnum.nodeResponse]?: ChatHistoryItemResType[];
};
export type ChatItemValueItemType =
| UserChatItemValueItemType
| SystemChatItemValueItemType
| AIChatItemValueItemType;
export type ChatItemSchema = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
dataId: string;
chatId: string;
userId: string;
teamId: string;
tmbId: string;
appId: string;
time: Date;
durationSeconds?: number;
errorMsg?: string;
};
export type ChatFeedbackLogSchema = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
dataId: string;
chatId: string;
userId: string;
teamId: string;
tmbId: string;
appId: string;
time: Date;
qvalue: UserChatItemValueItemType[];
status: string;
responseData?: ChatHistoryItemResType[];
// Additional properties used in the application
appName?: string;
datasetName?: string;
datasetList?: Array<{ datasetId: string; name?: string }>;
q?: string;
a?: string;
};
export type ChatFeedbackLogRelationSchema = {
datasetId: string;
collectionId: string;
};
export type AdminFbkType = {
feedbackDataId: string;
datasetId: string;
collectionId: string;
q: string;
a?: string;
};
/* --------- chat item ---------- */
export type ResponseTagItemType = {
totalQuoteList?: SearchDataResponseItemType[];
llmModuleAccount?: number;
historyPreviewLength?: number;
toolCiteLinks?: ToolCiteLinksType[];
};
export type ChatItemType = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
dataId?: string;
} & ResponseTagItemType;
// Frontend type
export type ChatSiteItemType = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
_id?: string;
dataId: string;
status: `${ChatStatusEnum}`;
moduleName?: string;
ttsBuffer?: Uint8Array;
responseData?: ChatHistoryItemResType[];
time?: Date;
durationSeconds?: number;
errorMsg?: string;
} & ChatBoxInputType &
ResponseTagItemType;
/* --------- team chat --------- */
export type ChatAppListSchema = {
apps: AppType[];
teamInfo: teamInfoSchema;
uid?: string;
};
/* ---------- history ------------- */
export type HistoryItemType = {
chatId: string;
updateTime: Date;
customTitle?: string;
title: string;
};
export type ChatHistoryItemType = HistoryItemType & {
appId: string;
top: boolean;
};
/* ------- response data ------------ */
export type ChatHistoryItemResType = DispatchNodeResponseType & {
nodeId: string;
id: string;
moduleType: FlowNodeTypeEnum;
moduleName: string;
};
/* ---------- node outputs ------------ */
export type NodeOutputItemType = {
nodeId: string;
key: NodeOutputKeyEnum;
value: any;
};
/* One tool run response */
export type ToolRunResponseItemType = any;
/* tool module response */
export type ToolModuleResponseItemType = {
id: string;
toolName: string; // tool name
toolAvatar: string;
params: string; // tool params
response: string;
functionName: string;
};
export type ToolCiteLinksType = {
name: string;
url: string;
};
/* dispatch run time */
export type RuntimeUserPromptType = {
files: UserChatItemValueItemType['file'][];
text: string;
};
import { RequireOnlyOne } from '../../../common/type/utils';
import type { ParentIdType } from '../../../common/parentFolder/type';
export type APIFileItemType = {
id: string;
rawId: string;
parentId: ParentIdType;
name: string;
type: 'file' | 'folder';
updateTime: Date;
createTime: Date;
hasChild?: boolean;
};
// Api dataset config
export type APIFileServer = {
baseUrl: string;
authorization?: string;
basePath?: string;
};
export type FeishuServer = {
appId: string;
appSecret?: string;
folderToken: string;
};
export type YuqueServer = {
userId: string;
token?: string;
basePath?: string;
};
export type ApiDatasetServerType = {
apiServer?: APIFileServer;
feishuServer?: FeishuServer;
yuqueServer?: YuqueServer;
};
// Api dataset api
export type ApiFileReadContentResponse = {
title?: string;
rawText: string;
};
export type APIFileReadResponse = {
url: string;
};
export type ApiDatasetDetailResponse = APIFileItemType;
import type { UpdateClbPermissionProps } from '../../support/permission/collaborator';
import { PermissionValueType } from '../../support/permission/type';
import type { RequireOnlyOne } from '../../common/type/utils';
export type UpdateDatasetCollaboratorBody = UpdateClbPermissionProps & {
datasetId: string;
};
export type DatasetCollaboratorDeleteParams = {
datasetId: string;
} & RequireOnlyOne<{
tmbId: string;
groupId: string;
orgId: string;
}>;
export type DatasetImageSchema = {
_id: string;
teamId: string;
datasetId: string;
collectionId?: string;
name: string;
contentType: string;
size: number;
metadata?: Record<string, any>;
expiredTime?: Date;
createdAt: Date;
updatedAt: Date;
};
import type { LLMModelItemType, EmbeddingModelItemType } from '../../core/ai/model.d';
import { PermissionTypeEnum } from '../../support/permission/constant';
import { PushDatasetDataChunkProps } from './api';
import type {
DataChunkSplitModeEnum,
DatasetCollectionDataProcessModeEnum,
DatasetCollectionTypeEnum,
DatasetStatusEnum,
DatasetTypeEnum,
SearchScoreTypeEnum,
TrainingModeEnum,
ChunkSettingModeEnum,
ChunkTriggerConfigTypeEnum
} from './constants';
import type { DatasetPermission } from '../../support/permission/dataset/controller';
import type {
ApiDatasetServerType,
APIFileServer,
FeishuServer,
YuqueServer
} from './apiDataset/type';
import type { SourceMemberType } from 'support/user/type';
import type { DatasetDataIndexTypeEnum } from './data/constants';
import type { ParentIdType } from 'common/parentFolder/type';
export type ChunkSettingsType = {
trainingType?: DatasetCollectionDataProcessModeEnum;
// Chunk trigger
chunkTriggerType?: ChunkTriggerConfigTypeEnum;
chunkTriggerMinSize?: number; // maxSize from agent model, not store
// Data enhance
dataEnhanceCollectionName?: boolean; // Auto add collection name to data
// Index enhance
imageIndex?: boolean;
autoIndexes?: boolean;
indexPrefixTitle?: boolean;
// Chunk setting
chunkSettingMode?: ChunkSettingModeEnum; // 系统参数/自定义参数
chunkSplitMode?: DataChunkSplitModeEnum;
// Paragraph split
paragraphChunkAIMode?: ParagraphChunkAIModeEnum;
paragraphChunkDeep?: number; // Paragraph deep
paragraphChunkMinSize?: number; // Paragraph min size, if too small, it will merge
// Size split
chunkSize?: number; // chunk/qa chunk size, Paragraph max chunk size.
// Char split
chunkSplitter?: string; // chunk/qa chunk splitter
indexSize?: number;
qaPrompt?: string;
};
export type DatasetSchemaType = {
_id: string;
parentId: ParentIdType;
userId: string;
teamId: string;
tmbId: string;
updateTime: Date;
avatar: string;
name: string;
intro: string;
type: `${DatasetTypeEnum}`;
vectorModel: string;
agentModel: string;
vlmModel?: string;
websiteConfig?: {
url: string;
selector: string;
};
chunkSettings?: ChunkSettingsType;
inheritPermission: boolean;
apiDatasetServer?: ApiDatasetServerType;
// abandon
autoSync?: boolean;
externalReadUrl?: string;
defaultPermission?: number;
apiServer?: APIFileServer;
feishuServer?: FeishuServer;
yuqueServer?: YuqueServer;
};
export type DatasetCollectionSchemaType = ChunkSettingsType & {
_id: string;
teamId: string;
tmbId: string;
datasetId: string;
parentId?: string;
name: string;
type: DatasetCollectionTypeEnum;
tags?: string[];
createTime: Date;
updateTime: Date;
// Status
forbid?: boolean;
// Collection metadata
fileId?: string; // local file id
rawLink?: string; // link url
externalFileId?: string; //external file id
apiFileId?: string; // api file id
apiFileParentId?: string;
externalFileUrl?: string; // external import url
rawTextLength?: number;
hashRawText?: string;
metadata?: {
webPageSelector?: string;
relatedImgId?: string; // The id of the associated image collections
[key: string]: any;
};
// Parse settings
customPdfParse?: boolean;
trainingType: DatasetCollectionDataProcessModeEnum;
};
export type DatasetCollectionTagsSchemaType = {
_id: string;
teamId: string;
datasetId: string;
tag: string;
};
export type DatasetDataIndexItemType = {
type: `${DatasetDataIndexTypeEnum}`;
dataId: string; // pg data id
text: string;
};
export type DatasetDataFieldType = {
q: string; // large chunks or question
a?: string; // answer or custom content
imageId?: string;
};
export type DatasetDataSchemaType = DatasetDataFieldType & {
_id: string;
userId: string;
teamId: string;
tmbId: string;
datasetId: string;
collectionId: string;
chunkIndex: number;
updateTime: Date;
history?: (DatasetDataFieldType & {
updateTime: Date;
})[];
forbid?: boolean;
fullTextToken: string;
indexes: DatasetDataIndexItemType[];
rebuilding?: boolean;
imageDescMap?: Record<string, string>;
};
export type DatasetDataTextSchemaType = {
_id: string;
teamId: string;
datasetId: string;
collectionId: string;
dataId: string;
fullTextToken: string;
};
export type DatasetTrainingSchemaType = {
_id: string;
userId: string;
teamId: string;
tmbId: string;
datasetId: string;
collectionId: string;
billId: string;
expireAt: Date;
lockTime: Date;
mode: TrainingModeEnum;
dataId?: string;
q: string;
a: string;
imageId?: string;
imageDescMap?: Record<string, string>;
chunkIndex: number;
indexSize?: number;
weight: number;
indexes: Omit<DatasetDataIndexItemType, 'dataId'>[];
retryCount: number;
errorMsg?: string;
};
export type CollectionWithDatasetType = DatasetCollectionSchemaType & {
dataset: DatasetSchemaType;
};
/* ================= dataset ===================== */
export type DatasetSimpleItemType = {
_id: string;
avatar: string;
name: string;
vectorModel: EmbeddingModelItemType;
};
export type DatasetListItemType = {
_id: string;
tmbId: string;
avatar: string;
updateTime: Date;
name: string;
intro: string;
type: `${DatasetTypeEnum}`;
permission: DatasetPermission;
vectorModel: EmbeddingModelItemType;
inheritPermission: boolean;
private?: boolean;
sourceMember?: SourceMemberType;
};
export type DatasetItemType = Omit<DatasetSchemaType, 'vectorModel' | 'agentModel' | 'vlmModel'> & {
status: `${DatasetStatusEnum}`;
errorMsg?: string;
vectorModel: EmbeddingModelItemType;
agentModel: LLMModelItemType;
vlmModel?: LLMModelItemType;
permission: DatasetPermission;
};
/* ================= tag ===================== */
export type DatasetTagType = {
_id: string;
tag: string;
};
export type TagUsageType = {
tagId: string;
collections: string[];
};
/* ================= collection ===================== */
export type DatasetCollectionItemType = CollectionWithDatasetType & {
sourceName: string;
sourceId?: string;
file?: DatasetFileSchema;
permission: DatasetPermission;
indexAmount: number;
errorCount?: number;
};
/* ================= data ===================== */
export type DatasetDataItemType = DatasetDataFieldType & {
id: string;
teamId: string;
datasetId: string;
imagePreivewUrl?: string;
updateTime: Date;
collectionId: string;
sourceName: string;
sourceId?: string;
chunkIndex: number;
indexes: DatasetDataIndexItemType[];
isOwner: boolean;
};
/* --------------- file ---------------------- */
export type DatasetFileSchema = {
_id: string;
length: number;
chunkSize: number;
uploadDate: Date;
filename: string;
contentType: string;
metadata: {
teamId: string;
tmbId?: string;
uid: string;
encoding?: string;
};
};
/* ============= search =============== */
export type SearchDataResponseItemType = Omit<
DatasetDataItemType,
'teamId' | 'indexes' | 'isOwner'
> & {
score: { type: `${SearchScoreTypeEnum}`; value: number; index: number }[];
// score: number;
};
export type DatasetCiteItemType = {
_id: string;
q: string;
a?: string;
imagePreivewUrl?: string;
history?: DatasetDataSchemaType['history'];
updateTime: DatasetDataSchemaType['updateTime'];
index: DatasetDataSchemaType['chunkIndex'];
updated?: boolean;
};
import type { ChatNodeUsageType } from '../../../support/wallet/bill/type';
import type {
ChatItemType,
ToolRunResponseItemType,
AIChatItemValueItemType
} from '../../chat/type';
import { NodeOutputItemType } from '../../chat/type';
import type { FlowNodeInputItemType, FlowNodeOutputItemType } from '../type/io.d';
import type { NodeToolConfigType, StoreNodeItemType } from '../type/node';
import type { DispatchNodeResponseKeyEnum } from './constants';
import type { StoreEdgeItemType } from '../type/edge';
import type { NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants';
import type { ClassifyQuestionAgentItemType } from '../template/system/classifyQuestion/type';
import type { NextApiResponse } from 'next';
import { UserModelSchema } from '../../../support/user/type';
import type { AppSchema } from '../../app/type';
import { AppDetailType } from '../../app/type';
import type { RuntimeNodeItemType } from '../runtime/type';
import type { RuntimeEdgeItemType } from './edge';
import type { ReadFileNodeResponse } from '../template/system/readFiles/type';
import { UserSelectOptionType } from '../template/system/userSelect/type';
import type { WorkflowResponseType } from '../../../../service/core/workflow/dispatch/type';
import type { AiChatQuoteRoleType } from '../template/system/aiChat/type';
import type { OpenaiAccountType } from '../../../support/user/team/type';
import { LafAccountType } from '../../../support/user/team/type';
import type { CompletionFinishReason } from '../../ai/type';
import type {
InteractiveNodeResponseType,
WorkflowInteractiveResponseType
} from '../template/system/interactive/type';
import type { SearchDataResponseItemType } from '../../dataset/type';
import type { localeType } from '../../../common/i18n/type';
export type ExternalProviderType = {
openaiAccount?: OpenaiAccountType;
externalWorkflowVariables?: Record<string, string>;
};
/* workflow props */
export type ChatDispatchProps = {
res?: NextApiResponse;
lang?: localeType;
requestOrigin?: string;
mode: 'test' | 'chat' | 'debug';
timezone: string;
externalProvider: ExternalProviderType;
runningAppInfo: {
id: string; // May be the id of the system plug-in (cannot be used directly to look up the table)
teamId: string;
tmbId: string; // App tmbId
isChildApp?: boolean;
};
runningUserInfo: {
username: string;
teamName: string;
memberName: string;
contact: string;
teamId: string;
tmbId: string;
};
uid: string; // Who run this workflow
chatId?: string;
responseChatItemId?: string;
histories: ChatItemType[];
variables: Record<string, any>; // global variable
query: UserChatItemValueItemType[]; // trigger query
chatConfig: AppSchema['chatConfig'];
lastInteractive?: WorkflowInteractiveResponseType; // last interactive response
stream: boolean;
retainDatasetCite?: boolean;
maxRunTimes: number;
isToolCall?: boolean;
workflowStreamResponse?: WorkflowResponseType;
workflowDispatchDeep?: number;
version?: 'v1' | 'v2';
responseAllData?: boolean;
responseDetail?: boolean;
};
export type ModuleDispatchProps<T> = ChatDispatchProps & {
node: RuntimeNodeItemType;
runtimeNodes: RuntimeNodeItemType[];
runtimeEdges: RuntimeEdgeItemType[];
params: T;
};
export type SystemVariablesType = {
userId: string;
appId: string;
chatId?: string;
responseChatItemId?: string;
histories: ChatItemType[];
cTime: string;
};
/* node props */
export type RuntimeNodeItemType = {
nodeId: StoreNodeItemType['nodeId'];
name: StoreNodeItemType['name'];
avatar: StoreNodeItemType['avatar'];
intro?: StoreNodeItemType['intro'];
toolDescription?: StoreNodeItemType['toolDescription'];
flowNodeType: StoreNodeItemType['flowNodeType'];
showStatus?: StoreNodeItemType['showStatus'];
isEntry?: boolean;
version?: string;
inputs: FlowNodeInputItemType[];
outputs: FlowNodeOutputItemType[];
pluginId?: string; // workflow id / plugin id
// Tool
toolConfig?: StoreNodeItemType['toolConfig'];
// catch error
catchError?: boolean;
};
export type RuntimeEdgeItemType = StoreEdgeItemType & {
status: 'waiting' | 'active' | 'skipped';
};
export type DispatchNodeResponseType = {
// common
moduleLogo?: string;
runningTime?: number;
query?: string;
textOutput?: string;
// Client will toast
error?: Record<string, any> | string;
// Just show
errorText?: string;
customInputs?: Record<string, any>;
customOutputs?: Record<string, any>;
nodeInputs?: Record<string, any>;
nodeOutputs?: Record<string, any>;
mergeSignId?: string;
// bill
tokens?: number; // deprecated
inputTokens?: number;
outputTokens?: number;
model?: string;
contextTotalLen?: number;
totalPoints?: number;
childTotalPoints?: number;
// chat
temperature?: number;
maxToken?: number;
quoteList?: SearchDataResponseItemType[];
reasoningText?: string;
historyPreview?: {
obj: `${ChatRoleEnum}`;
value: string;
}[]; // completion context array. history will slice
finishReason?: CompletionFinishReason;
// dataset search
embeddingModel?: string;
embeddingTokens?: number;
similarity?: number;
limit?: number;
searchMode?: `${DatasetSearchModeEnum}`;
embeddingWeight?: number;
rerankModel?: string;
rerankWeight?: number;
reRankInputTokens?: number;
searchUsingReRank?: boolean;
queryExtensionResult?: {
model: string;
inputTokens: number;
outputTokens: number;
query: string;
};
deepSearchResult?: {
model: string;
inputTokens: number;
outputTokens: number;
};
// dataset concat
concatLength?: number;
// cq
cqList?: ClassifyQuestionAgentItemType[];
cqResult?: string;
// content extract
extractDescription?: string;
extractResult?: Record<string, any>;
// http
params?: Record<string, any>;
body?: Record<string, any> | string;
headers?: Record<string, any>;
httpResult?: Record<string, any>;
// plugin output
pluginOutput?: Record<string, any>;
pluginDetail?: ChatHistoryItemResType[];
// if-else
ifElseResult?: string;
// tool
toolCallInputTokens?: number;
toolCallOutputTokens?: number;
toolDetail?: ChatHistoryItemResType[];
toolStop?: boolean;
// code
codeLog?: string;
// plugin
pluginOutput?: Record<string, any>;
// read files
readFilesResult?: string;
readFiles?: ReadFileNodeResponse;
// user select
userSelectResult?: string;
// update var
updateVarResult?: any[];
// loop
loopResult?: any[];
loopInput?: any[];
loopDetail?: ChatHistoryItemResType[];
// loop start
loopInputValue?: any;
// loop end
loopOutputValue?: any;
// form input
formInputResult?: string;
// tool params
toolParamsResult?: Record<string, any>;
toolRes?: any;
// abandon
extensionModel?: string;
extensionResult?: string;
extensionTokens?: number;
};
export type DispatchNodeResultType<T = {}, ERR = { [NodeOutputKeyEnum.errorText]?: string }> = {
[DispatchNodeResponseKeyEnum.answerText]?: string;
[DispatchNodeResponseKeyEnum.reasoningText]?: string;
[DispatchNodeResponseKeyEnum.skipHandleId]?: string[]; // skip some edge handle id
[DispatchNodeResponseKeyEnum.nodeResponse]?: DispatchNodeResponseType; // The node response detail
[DispatchNodeResponseKeyEnum.nodeDispatchUsages]?: ChatNodeUsageType[]; // Node total usage
[DispatchNodeResponseKeyEnum.childrenResponses]?: DispatchNodeResultType[]; // Children node response
[DispatchNodeResponseKeyEnum.toolResponses]?: ToolRunResponseItemType; // Tool response
[DispatchNodeResponseKeyEnum.assistantResponses]?: AIChatItemValueItemType[]; // Assistant response(Store to db)
[DispatchNodeResponseKeyEnum.rewriteHistories]?: ChatItemType[];
[DispatchNodeResponseKeyEnum.runTimes]?: number;
[DispatchNodeResponseKeyEnum.newVariables]?: Record<string, any>;
[DispatchNodeResponseKeyEnum.memories]?: Record<string, any>;
[DispatchNodeResponseKeyEnum.interactive]?: InteractiveNodeResponseType;
data?: T;
error?: ERR;
};
/* Single node props */
export type AIChatNodeProps = {
[NodeInputKeyEnum.aiModel]: string;
[NodeInputKeyEnum.aiSystemPrompt]?: string;
[NodeInputKeyEnum.aiChatTemperature]?: number;
[NodeInputKeyEnum.aiChatMaxToken]?: number;
[NodeInputKeyEnum.aiChatIsResponseText]: boolean;
[NodeInputKeyEnum.aiChatVision]?: boolean;
[NodeInputKeyEnum.aiChatReasoning]?: boolean;
[NodeInputKeyEnum.aiChatTopP]?: number;
[NodeInputKeyEnum.aiChatStopSign]?: string;
[NodeInputKeyEnum.aiChatResponseFormat]?: string;
[NodeInputKeyEnum.aiChatJsonSchema]?: string;
[NodeInputKeyEnum.aiChatQuoteRole]?: AiChatQuoteRoleType;
[NodeInputKeyEnum.aiChatQuoteTemplate]?: string;
[NodeInputKeyEnum.aiChatQuotePrompt]?: string;
[NodeInputKeyEnum.stringQuoteText]?: string;
[NodeInputKeyEnum.fileUrlList]?: string[];
};
export type SelectAppItemType = {
id: string;
// name: string;
// logo?: string;
};
export type ClassifyQuestionAgentItemType = {
value: string;
key: string;
};
import type { WorkflowIOValueTypeEnum } from '../../../constants';
export type ContextExtractAgentItemType = {
valueType:
| WorkflowIOValueTypeEnum.string
| WorkflowIOValueTypeEnum.number
| WorkflowIOValueTypeEnum.boolean
| WorkflowIOValueTypeEnum.arrayString
| WorkflowIOValueTypeEnum.arrayNumber
| WorkflowIOValueTypeEnum.arrayBoolean;
desc: string;
key: string;
required: boolean;
defaultValue?: string;
enum?: string;
};
import type { ReferenceItemValueType } from '../../../type/io';
import type { VariableConditionEnum } from './constant';
export type IfElseConditionType = 'AND' | 'OR';
export type ConditionListItemType = {
variable?: ReferenceItemValueType;
condition?: VariableConditionEnum;
value?: string | ReferenceItemValueType;
valueType?: 'input' | 'reference';
};
export type IfElseListItemType = {
condition: IfElseConditionType;
list: ConditionListItemType[];
};
import type { NodeOutputItemType } from '../../../../chat/type';
import type { FlowNodeOutputItemType } from '../../../type/io';
import type { FlowNodeInputTypeEnum } from 'core/workflow/node/constant';
import type { WorkflowIOValueTypeEnum } from 'core/workflow/constants';
import type { ChatCompletionMessageParam } from '../../../../ai/type';
type InteractiveBasicType = {
entryNodeIds: string[];
memoryEdges: RuntimeEdgeItemType[];
nodeOutputs: NodeOutputItemType[];
toolParams?: {
entryNodeIds: string[]; // 记录工具中,交互节点的 Id,而不是起始工作流的入口
memoryMessages: ChatCompletionMessageParam[]; // 这轮工具中,产生的新的 messages
toolCallId: string; // 记录对应 tool 的id,用于后续交互节点可以替换掉 tool 的 response
};
};
type InteractiveNodeType = {
entryNodeIds?: string[];
memoryEdges?: RuntimeEdgeItemType[];
nodeOutputs?: NodeOutputItemType[];
};
type ChildrenInteractive = InteractiveNodeType & {
type: 'childrenInteractive';
params: {
childrenResponse?: WorkflowInteractiveResponseType;
};
};
type LoopInteractive = InteractiveNodeType & {
type: 'loopInteractive';
params: {
loopResult: any[];
childrenResponse: WorkflowInteractiveResponseType;
currentIndex: number;
};
};
export type UserSelectOptionItemType = {
key: string;
value: string;
};
type UserSelectInteractive = InteractiveNodeType & {
type: 'userSelect';
params: {
description: string;
userSelectOptions: UserSelectOptionItemType[];
userSelectedVal?: string;
};
};
export type UserInputFormItemType = {
type: FlowNodeInputTypeEnum;
key: string;
label: string;
value: any;
valueType: WorkflowIOValueTypeEnum;
description?: string;
defaultValue?: any;
required: boolean;
// input & textarea
maxLength?: number;
// numberInput
max?: number;
min?: number;
// select
list?: { label: string; value: string }[];
};
type UserInputInteractive = InteractiveNodeType & {
type: 'userInput';
params: {
description: string;
inputForm: UserInputFormItemType[];
submitted?: boolean;
};
};
export type InteractiveNodeResponseType =
| UserSelectInteractive
| UserInputInteractive
| ChildrenInteractive
| LoopInteractive;
export type WorkflowInteractiveResponseType = InteractiveBasicType & InteractiveNodeResponseType;
export type ReadFileNodeResponse = {
url: string;
name: string;
}[];
import type { FlowNodeInputTypeEnum } from '../../../node/constant';
import type { ReferenceItemValueType, ReferenceValueType } from '../../..//type/io';
import type { WorkflowIOValueTypeEnum } from '../../../constants';
export type TUpdateListItem = {
variable?: ReferenceItemValueType;
value?: ReferenceValueType; // input: ['',value], reference: [nodeId,outputId]
valueType?: WorkflowIOValueTypeEnum;
renderType: FlowNodeInputTypeEnum.input | FlowNodeInputTypeEnum.reference;
};
import type { RuntimeEdgeStatusEnum } from '../constants';
export type StoreEdgeItemType = {
source: string;
sourceHandle: string;
target: string;
targetHandle: string;
};
export type RuntimeEdgeItemType = StoreEdgeItemType & {
status: `${RuntimeEdgeStatusEnum}`;
};
import { FlowNodeTypeEnum } from '../node/constant';
import {
WorkflowIOValueTypeEnum,
NodeOutputKeyEnum,
FlowNodeTemplateTypeEnum,
VariableInputEnum
} from '../constants';
import { DispatchNodeResponseKeyEnum } from '../runtime/constants';
import type { FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d';
import { CustomInputItemType } from './io.d';
import {
ChatHistoryItemResType,
ChatItemType,
ChatItemValueItemType,
ToolRunResponseItemType
} from '../../chat/type';
import { ChatNodeUsageType } from '../../../support/wallet/bill/type';
import type { StoreEdgeItemType } from './edge';
import type { AppChatConfigType } from '../../app/type';
import type { ParentIdType } from 'common/parentFolder/type';
import type { AppTypeEnum } from 'core/app/constants';
import type { StoreNodeItemType } from './node';
import { FlowNodeTemplateType } from './node';
import type { SecretValueType } from './../../../common/secret/type';
import type { I18nStringType } from '../../../common/i18n/type';
export type WorkflowTemplateBasicType = {
nodes: StoreNodeItemType[];
edges: StoreEdgeItemType[];
chatConfig?: AppChatConfigType;
};
export type WorkflowTemplateType = {
id: string;
parentId?: ParentIdType;
isFolder?: boolean;
avatar: string;
name: I18nStringType | string;
intro?: I18nStringType | string;
toolDescription?: string;
author?: string;
courseUrl?: string;
weight?: number;
version?: string;
workflow: WorkflowTemplateBasicType;
};
// template market
export type TemplateMarketItemType = WorkflowTemplateType & {
tags: string[];
type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.plugin;
};
// template market list
export type TemplateMarketListItemType = {
id: string;
name: string;
intro?: string;
author?: string;
tags: string[];
type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.plugin;
avatar: string;
};
import type { EmbeddingModelItemType, LLMModelItemType } from '../../ai/model.d';
import type { LLMModelTypeEnum } from '../../ai/constants';
import type { WorkflowIOValueTypeEnum, NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants';
import type { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum } from '../node/constant';
import type { SecretValueType } from '../../../common/secret/type';
// Dynamic input field configuration
export type CustomFieldConfigType = {
// selectInputTypeList: FlowNodeInputTypeEnum[]; // 可以选哪些输入类型, 只有1个话,则默认选择
// reference
selectValueTypeList?: WorkflowIOValueTypeEnum[]; // 可以选哪个数据类型, 只有1个的话,则默认选择
showDefaultValue?: boolean;
showDescription?: boolean;
};
export type InputComponentPropsType = {
referencePlaceholder?: string;
placeholder?: string; // input,textarea
maxLength?: number; // input,textarea
list?: { label: string; value: string }[]; // select
markList?: { label: string; value: number }[]; // slider
step?: number; // slider
max?: number; // slider, number input
min?: number; // slider, number input
precision?: number; // number input
defaultValue?: string;
llmModelType?: `${LLMModelTypeEnum}`;
// dynamic input
customInputConfig?: CustomFieldConfigType;
};
export type InputConfigType = {
key: string;
label: string;
description?: string;
required?: boolean;
inputType: 'input' | 'numberInput' | 'secret' | 'switch' | 'select';
value?: SecretValueType;
// Selector
list?: { label: string; value: string }[];
};
export type FlowNodeInputItemType = InputComponentPropsType & {
selectedTypeIndex?: number;
renderTypeList: FlowNodeInputTypeEnum[]; // Node Type. Decide on a render style
key: `${NodeInputKeyEnum}` | string;
valueType?: WorkflowIOValueTypeEnum; // data type
valueDesc?: string; // data desc
value?: any;
label: string;
debugLabel?: string;
description?: string; // field desc
required?: boolean;
enum?: string;
inputList?: InputConfigType[]; // when key === 'system_input_config', this field is used
toolDescription?: string; // If this field is not empty, it is entered as a tool
// render components params
canEdit?: boolean; // dynamic inputs
isPro?: boolean; // Pro version field
isToolOutput?: boolean;
// file
canSelectFile?: boolean;
canSelectImg?: boolean;
maxFiles?: number;
deprecated?: boolean;
};
export type FlowNodeOutputItemType = {
id: string; // output unique id(Does not follow the key change)
type: FlowNodeOutputTypeEnum;
key: `${NodeOutputKeyEnum}` | string;
valueType?: WorkflowIOValueTypeEnum;
valueDesc?: string;
value?: any;
label?: string;
description?: string;
defaultValue?: any;
required?: boolean;
invalid?: boolean;
invalidCondition?: (e: {
inputs: FlowNodeInputItemType[];
llmModelList: LLMModelItemType[];
}) => boolean;
// component params
customFieldConfig?: CustomFieldConfigType;
deprecated?: boolean;
};
// Field value type
export type ReferenceItemValueType = [string, string | undefined];
export type ReferenceArrayValueType = ReferenceItemValueType[];
export type ReferenceValueType = ReferenceItemValueType | ReferenceArrayValueType;
export type SelectedDatasetType = {
datasetId: string;
avatar: string;
name: string;
vectorModel: EmbeddingModelItemType;
}[];
/* http node */
export type HttpParamAndHeaderItemType = {
key: string;
type: string;
value: string;
};
import type { FlowNodeTypeEnum } from '../node/constant';
import {
WorkflowIOValueTypeEnum,
NodeOutputKeyEnum,
FlowNodeTemplateTypeEnum,
VariableInputEnum
} from '../constants';
import { DispatchNodeResponseKeyEnum } from '../runtime/constants';
import type { FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d';
import { UserModelSchema } from '../../../support/user/type';
import type { ChatHistoryItemResType } from '../../chat/type';
import {
ChatItemType,
ChatItemValueItemType,
ToolRunResponseItemType,
UserChatItemValueItemType
} from '../../chat/type';
import { ChatNodeUsageType } from '../../../support/wallet/bill/type';
import { RuntimeNodeItemType } from '../runtime/type';
import { RuntimeEdgeItemType, StoreEdgeItemType } from './edge';
import { NextApiResponse } from 'next';
import type { AppDetailType, AppSchema, McpToolConfigType } from '../../app/type';
import type { ParentIdType } from 'common/parentFolder/type';
import { AppTypeEnum } from '../../app/constants';
import type { WorkflowInteractiveResponseType } from '../template/system/interactive/type';
import type { StoreSecretValueType } from '../../../common/secret/type';
export type NodeToolConfigType = {
mcpToolSet?: {
toolId: string; // ObjectId of the MCP App
url: string;
headerSecret?: StoreSecretValueType;
toolList: McpToolConfigType[];
};
mcpTool?: {
toolId: string;
};
systemTool?: {
toolId: string;
};
systemToolSet?: {
toolId: string;
toolList: {
toolId: string;
name: string;
description: string;
}[];
};
};
export type FlowNodeCommonType = {
parentNodeId?: string;
flowNodeType: FlowNodeTypeEnum; // render node card
abandon?: boolean; // abandon node
avatar?: string;
name: string;
intro?: string; // template list intro
toolDescription?: string;
showStatus?: boolean; // chatting response step status
version?: string;
versionLabel?: string; // Just ui show
isLatestVersion?: boolean; // Just ui show
// data
catchError?: boolean;
inputs: FlowNodeInputItemType[];
outputs: FlowNodeOutputItemType[];
// plugin data
pluginId?: string;
isFolder?: boolean;
pluginData?: PluginDataType;
// tool data
toolConfig?: NodeToolConfigType;
// Not store, just computed
currentCost?: number;
systemKeyCost?: number;
hasTokenFee?: boolean;
hasSystemSecret?: boolean;
};
export type PluginDataType = {
diagram?: string;
userGuide?: string;
courseUrl?: string;
name?: string;
avatar?: string;
error?: string;
};
type HandleType = {
left: boolean;
right: boolean;
top: boolean;
bottom: boolean;
};
// system template
export type FlowNodeTemplateType = FlowNodeCommonType & {
id: string; // node id, unique
templateType: string;
showSourceHandle?: boolean;
showTargetHandle?: boolean;
// info
isTool?: boolean; // can be connected by tool
// action
forbidDelete?: boolean; // forbid delete
unique?: boolean;
diagram?: string; // diagram url
courseUrl?: string; // course url
userGuide?: string; // user guide
// @deprecated
// show handle
sourceHandle?: HandleType;
targetHandle?: HandleType;
};
export type NodeTemplateListItemType = {
id: string; // 系统节点-系统节点的 id, 系统插件-插件的 id,团队应用的 id
flowNodeType: FlowNodeTypeEnum; // render node card
parentId?: ParentIdType;
isFolder?: boolean;
templateType: string;
avatar?: string;
name: string;
intro?: string; // template list intro
isTool?: boolean;
authorAvatar?: string;
author?: string;
unique?: boolean; // 唯一的
currentCost?: number; // 当前积分消耗
systemKeyCost?: number; // 系统密钥费用,统一为数字
hasTokenFee?: boolean; // 是否配置积分
instructions?: string; // 使用说明
courseUrl?: string; // 教程链接
sourceMember?: SourceMember;
};
export type NodeTemplateListType = {
type: string;
label: string;
list: NodeTemplateListItemType[];
}[];
// react flow node type
export type FlowNodeItemType = FlowNodeTemplateType & {
nodeId: string;
parentNodeId?: string;
isError?: boolean;
searchedText?: string;
debugResult?: {
status: 'running' | 'success' | 'skipped' | 'failed';
message?: string;
showResult?: boolean; // show and hide result modal
response?: ChatHistoryItemResType;
isExpired?: boolean;
workflowInteractiveResponse?: WorkflowInteractiveResponseType;
};
isFolded?: boolean;
};
// store node type
export type StoreNodeItemType = FlowNodeCommonType & {
nodeId: string;
// isEntry: boolean;
position?: {
x: number;
y: number;
};
};
export type PromotionRecordSchema = {
_id: string;
userId: string; // 收益人
objUId?: string; // 目标对象(如果是withdraw则为空)
type: 'register' | 'pay';
createTime: Date; // 记录时间
amount: number;
};
export type ShortUrlParams = {
shortUrlSource?: string; // Article, video
shortUrlMedium?: string; // bilibili, youtube
shortUrlContent?: string; // project id
};
export type TrackRegisterParams = {
inviterId?: string;
bd_vid?: string;
msclkid?: string;
fastgpt_sem?: {
keyword?: string;
search?: string;
} & ShortUrlParams;
sourceDomain?: string;
};
export type McpKeyType = {
_id: string;
key: string;
teamId: string;
tmbId: string;
apps: McpAppType[];
name: string;
};
export type McpAppType = {
appId: string;
appName?: string;
toolName: string;
description: string;
};
export type OpenApiSchema = {
_id: string;
teamId: string;
tmbId: string;
createTime: Date;
lastUsedTime?: Date;
apiKey: string;
appId?: string;
name: string;
usagePoints: number;
limit?: {
expiredTime?: Date;
maxUsagePoints: number;
};
};
import type { HistoryItemType } from '../../core/chat/type.d';
import type { OutLinkSchema } from './type.d';
export type AuthOutLinkInitProps = {
outLinkUid: string;
tokenUrl?: string;
};
export type AuthOutLinkChatProps = { ip?: string | null; outLinkUid: string; question: string };
export type AuthOutLinkLimitProps = AuthOutLinkChatProps & { outLink: OutLinkSchema };
export type AuthOutLinkResponse = {
uid: string;
};
export type PostShareLoginProps = {
shareId: string;
password: string;
};
import { AppSchema } from '../../core/app/type';
import type { PublishChannelEnum } from './constant';
// Feishu Config interface
export interface FeishuAppType {
appId: string;
appSecret: string;
// Encrypt config
// refer to: https://open.feishu.cn/document/server-docs/event-subscription-guide/event-subscription-configure-/configure-encrypt-key
encryptKey?: string; // no secret if null
// Token Verification
// refer to: https://open.feishu.cn/document/server-docs/event-subscription-guide/event-subscription-configure-/encrypt-key-encryption-configuration-case
verificationToken?: string;
}
export interface DingtalkAppType {
clientId: string;
clientSecret: string;
}
export interface WecomAppType {
AgentId: string;
CorpId: string;
SuiteSecret: string;
CallbackToken: string;
CallbackEncodingAesKey: string;
}
// TODO: unused
export interface WechatAppType {}
export interface OffiAccountAppType {
appId: string;
isVerified?: boolean; // if isVerified, we could use '客服接口' to reply
secret: string;
CallbackToken: string;
CallbackEncodingAesKey?: string;
timeoutReply?: string; // if timeout (15s), will reply this content.
// timeout reply is optional, but when isVerified is false, the wechat will reply a default message which is `该公众号暂时无法提供服务,请稍后再试`
// because we can not reply anything in 15s. Thus, the wechat server will treat this request as a failed request.
}
export type OutlinkAppType =
| FeishuAppType
| WecomAppType
| OffiAccountAppType
| DingtalkAppType
| undefined;
export type OutLinkSchema<T extends OutlinkAppType = undefined> = {
_id: string;
shareId: string;
teamId: string;
tmbId: string;
appId: string;
name: string;
usagePoints: number;
lastTime: Date;
type: PublishChannelEnum;
// whether the response content is detailed
responseDetail: boolean;
// whether to hide the node status
showNodeStatus?: boolean;
// wheter to show the full text reader
// showFullText?: boolean;
// whether to show the complete quote
showRawSource?: boolean;
// response when request
immediateResponse?: string;
// response when error or other situation
defaultResponse?: string;
limit?: {
expiredTime?: Date;
// Questions per minute
QPM: number;
maxUsagePoints: number;
// Verification message hook url
hookUrl?: string;
password?: string;
};
app: T;
};
// Edit the Outlink
export type OutLinkEditType<T = undefined> = {
_id?: string;
name: string;
responseDetail?: OutLinkSchema<T>['responseDetail'];
showNodeStatus?: OutLinkSchema<T>['showNodeStatus'];
// showFullText?: OutLinkSchema<T>['showFullText'];
showRawSource?: OutLinkSchema<T>['showRawSource'];
// response when request
immediateResponse?: string;
// response when error or other situation
defaultResponse?: string;
limit?: OutLinkSchema<T>['limit'];
// config for specific platform
app?: T;
};
type ShareChatAuthProps = {
shareId?: string;
outLinkUid?: string;
};
type TeamChatAuthProps = {
teamId?: string;
teamToken?: string;
};
export type OutLinkChatAuthProps = ShareChatAuthProps & TeamChatAuthProps;
import type { RequireOnlyOne } from '../../common/type/utils';
import { RequireAtLeastOne } from '../../common/type/utils';
import type { Permission } from './controller';
import type { PermissionValueType } from './type';
export type CollaboratorItemType = {
teamId: string;
permission: Permission;
name: string;
avatar: string;
} & RequireOnlyOne<{
tmbId: string;
groupId: string;
orgId: string;
}>;
export type UpdateClbPermissionProps<addOnly = false> = {
members?: string[];
groups?: string[];
orgs?: string[];
} & (addOnly extends true
? {}
: {
permission: PermissionValueType;
});
export type DeletePermissionQuery = RequireOnlyOne<{
tmbId?: string;
groupId?: string;
orgId?: string;
}>;
export type GetGroupListBody = {
searchKey?: string;
withMembers?: boolean;
};
import { TeamMemberItemType } from 'support/user/team/type';
import { TeamPermission } from '../user/controller';
import type { GroupMemberRole } from './constant';
import type { Permission } from '../controller';
type MemberGroupSchemaType = {
_id: string;
teamId: string;
name: string;
avatar: string;
updateTime: Date;
};
type GroupMemberSchemaType = {
groupId: string;
tmbId: string;
role: `${GroupMemberRole}`;
};
type MemberGroupListItemType<WithMembers extends boolean | undefined> = MemberGroupSchemaType & {
members: WithMembers extends true
? {
tmbId: string;
name: string;
avatar: string;
}[]
: undefined;
count: WithMembers extends true ? number : undefined;
owner?: WithMembers extends true
? {
tmbId: string;
name: string;
avatar: string;
}
: undefined;
permission: WithMembers extends true ? Permission : undefined;
};
type GroupMemberItemType = {
tmbId: string;
name: string;
avatar: string;
role: `${GroupMemberRole}`;
};
import type { UserModelSchema } from '../user/type';
import type { RequireOnlyOne } from '../../common/type/utils';
import type { TeamMemberSchema } from '../user/team/type';
import { MemberGroupSchemaType } from './memberGroup/type';
import type { TeamMemberWithUserSchema } from '../user/team/type';
import type { CommonPerKeyEnum, CommonRoleKeyEnum } from './constant';
import { AuthUserTypeEnum, type CommonPerKeyEnum, type PerResourceTypeEnum } from './constant';
// PermissionValueType, the type of permission's value is a number, which is a bit field actually.
// It is spired by the permission system in Linux.
// The lowest 3 bits present the permission of reading, writing and managing.
// The higher bits are advanced permissions or extended permissions, which could be customized.
export type PermissionValueType = number;
export type RoleValueType = number;
export type ResourceType = `${PerResourceTypeEnum}`;
/**
* Define the roles. Each role is a binary number, only one bit is set to 1.
*/
export type RoleListType<T = {}> = Readonly<
Record<
T | CommonRoleKeyEnum,
Readonly<{
name: string;
description: string;
value: RoleValueType;
checkBoxType: 'single' | 'multiple';
}>
>
>;
/**
* Define the permissions. Each permission is a binary number, only one bit is set to 1.
* @example
* CommonPerList = {
* read: 0b100,
* write: 0b010,
* manage: 0b001
* }
* @example_bad
* CommonPerList = {
* write: 0b110, // bad, should be 0b010
* }
*/
export type PermissionListType<T = {}> = Readonly<
Record<T | CommonPerKeyEnum, PermissionValueType>
>;
/**
* Define the role-permission map. Each role has a permission.
* @key: role (binary number), only one bit is set to 1.
* @value: permission (binary number), multiple bits are set to 1.
* @example
* CommonRolePerMap = {
* 0b100: 0b100,
* 0b010: 0b110,
* 0b001: 0b111
* }
*/
export type RolePerMapType = Readonly<Map<RoleValueType, PermissionValueType>>;
export type ResourcePermissionType = {
teamId: string;
resourceType: ResourceType;
permission: PermissionValueType;
resourceId: string;
} & RequireOnlyOne<{
tmbId: string;
groupId: string;
orgId: string;
}>;
export type ResourcePerWithTmbWithUser = Omit<ResourcePermissionType, 'tmbId'> & {
tmbId: TeamMemberSchema & { user: UserModelSchema };
};
export type PermissionSchemaType = {
defaultPermission: PermissionValueType;
inheritPermission: boolean;
};
export type TmpDataSchema<T> = {
dataId: string;
data: T;
expireAt: Date;
};
import type { MemberGroupSchemaType } from 'support/permission/memberGroup/type';
import { MemberGroupListItemType } from 'support/permission/memberGroup/type';
import type { OAuthEnum } from './constant';
import type { TrackRegisterParams } from './login/api';
import { TeamMemberStatusEnum } from './team/constant';
import type { OrgType } from './team/org/type';
import type { TeamMemberItemType } from './team/type';
export type PostLoginProps = {
username: string;
password: string;
code: string;
};
export type OauthLoginProps = {
type: `${OAuthEnum}`;
callbackUrl: string;
props: Record<string, string>;
} & TrackRegisterParams;
export type WxLoginProps = {
inviterId?: string;
code: string;
bd_vid?: string;
msclkid?: string;
fastgpt_sem?: string;
sourceDomain?: string;
};
export type FastLoginProps = {
token: string;
code: string;
};
export type SearchResult = {
members: Omit<TeamMemberItemType, 'teamId' | 'permission'>[];
orgs: Omit<OrgType, 'permission' | 'members'>[];
groups: MemberGroupSchemaType[];
};
import type { SourceMemberType } from '../user/type';
import type { AuditEventEnum } from './constants';
export type OperationLogSchema = {
_id: string;
tmbId: string;
teamId: string;
timestamp: Date;
event: `${AuditEventEnum}`;
metadata?: Record<string, string>;
};
export type OperationListItemType = {
_id: string;
sourceMember: SourceMemberType;
event: `${AuditEventEnum}`;
timestamp: Date;
metadata: Record<string, string>;
};
import type { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
export type UserAuthSchemaType = {
key: string;
type: `${UserAuthTypeEnum}`;
code?: string;
openid?: string;
createTime: Date;
expiredTime: Date;
};
import type { InformLevelEnum, SendInformTemplateCodeEnum } from './constants';
export type SendInformProps = {
level: `${InformLevelEnum}`;
templateCode: `${SendInformTemplateCodeEnum}`;
templateParam: Record<string, any>;
customLockMinutes?: number; // custom lock minutes
};
export type SendInform2UserProps = SendInformProps & {
teamId: string;
};
export type SendInform2User = SendInformProps & {
type: `${InformTypeEnum}`;
tmbId: string;
};
export type UserInformSchema = {
_id: string;
userId: string;
teamId?: string;
time: Date;
level: `${InformLevelEnum}`;
title: string;
content: string;
read: boolean;
};
export type UserInformType = {
_id: string;
userId: string;
teamId?: string;
teamName?: string;
time: Date;
level: `${InformLevelEnum}`;
title: string;
content: string;
read: boolean;
};
import { PermissionValueType } from '../../permission/type';
import type { TeamMemberRoleEnum } from './constant';
import type { TeamMemberSchema, ThirdPartyAccountType } from './type';
import { LafAccountType } from './type';
export type AuthTeamRoleProps = {
teamId: string;
tmbId: string;
role?: `${TeamMemberRoleEnum}`;
};
export type CreateTeamProps = {
name: string;
avatar?: string;
memberName?: string;
memberAvatar?: string;
notificationAccount?: string;
};
export type UpdateTeamProps = Omit<ThirdPartyAccountType, 'externalWorkflowVariable'> & {
name?: string;
avatar?: string;
teamDomain?: string;
externalWorkflowVariable?: { key: string; value: string };
};
/* ------------- member ----------- */
export type DelMemberProps = {
tmbId: string;
};
export type UpdateTeamMemberProps = {
teamId: string;
memberId: string;
role?: TeamMemberSchema['role'];
status?: TeamMemberSchema['status'];
};
export type InviteMemberProps = {
teamId: string;
usernames: string[];
};
export type UpdateInviteProps = {
tmbId: string;
status: TeamMemberSchema['status'];
};
export type InviteMemberResponse = Record<
'invite' | 'inValid' | 'inTeam',
{ username: string; userId: string }[]
>;
import type { GroupMemberRole } from '../../../../support/permission/memberGroup/constant';
export type postCreateGroupData = {
name: string;
avatar?: string;
memberIdList?: string[];
};
export type putUpdateGroupData = {
groupId: string;
name?: string;
avatar?: string;
memberList?: {
tmbId: string;
role: `${GroupMemberRole}`;
}[];
};
export type postCreateOrgData = {
name: string;
description?: string;
avatar?: string;
orgId?: string;
};
export type putUpdateOrgMembersData = {
orgId?: string;
members: {
tmbId: string;
// role: `${OrgMemberRole}`;
}[];
};
export type putUpdateOrgData = {
orgId: string; // can not be undefined because can not uppdate root org
name?: string;
avatar?: string;
description?: string;
};
export type putMoveOrgType = {
orgId: string;
targetOrgId?: string; // '' ===> move to root org
};
// type putChnageOrgOwnerData = {
// orgId: string;
// tmbId: string;
// toAdmin?: boolean;
// };
import type { TeamPermission } from '../../../permission/user/controller';
import { ResourcePermissionType } from '../type';
import { SourceMemberType } from '../../type';
type OrgSchemaType = {
_id: string;
teamId: string;
pathId: string;
path: string;
name: string;
avatar: string;
description?: string;
updateTime: Date;
};
type OrgMemberSchemaType = {
_id: string;
teamId: string;
orgId: string;
tmbId: string;
};
export type OrgListItemType = OrgSchemaType & {
permission?: TeamPermission;
total: number; // members + children orgs
};
export type OrgType = Omit<OrgSchemaType, 'avatar'> & {
avatar: string;
permission: TeamPermission;
members: OrgMemberSchemaType[];
total: number; // members + children orgs
};
import type { UserModelSchema } from '../type';
import type { TeamMemberRoleEnum, TeamMemberStatusEnum } from './constant';
import type { LafAccountType } from './type';
import { PermissionValueType, ResourcePermissionType } from '../../permission/type';
import type { TeamPermission } from '../../permission/user/controller';
export type ThirdPartyAccountType = {
lafAccount?: LafAccountType;
openaiAccount?: OpenaiAccountType;
externalWorkflowVariables?: Record<string, string>;
};
export type TeamSchema = {
_id: string;
name: string;
ownerId: string;
avatar: string;
createTime: Date;
balance: number;
teamDomain: string;
limit: {
lastExportDatasetTime: Date;
lastWebsiteSyncTime: Date;
};
notificationAccount?: string;
} & ThirdPartyAccountType;
export type tagsType = {
label: string;
key: string;
};
export type TeamTagSchema = TeamTagItemType & {
_id: string;
teamId: string;
createTime: Date;
updateTime?: Date;
};
export type TeamMemberSchema = {
_id: string;
teamId: string;
userId: string;
createTime: Date;
updateTime?: Date;
name: string;
role: `${TeamMemberRoleEnum}` | 'admin';
status: `${TeamMemberStatusEnum}`;
avatar: string;
};
export type TeamMemberWithTeamAndUserSchema = TeamMemberSchema & {
team: TeamSchema;
user: UserModelSchema;
};
export type TeamTmbItemType = {
userId: string;
teamId: string;
teamAvatar?: string;
teamName: string;
memberName: string;
avatar: string;
balance?: number;
tmbId: string;
teamDomain: string;
role: `${TeamMemberRoleEnum}` | 'admin';
status: `${TeamMemberStatusEnum}`;
notificationAccount?: string;
permission: TeamPermission;
} & ThirdPartyAccountType;
export type TeamMemberItemType<
Options extends {
withPermission?: boolean;
withOrgs?: boolean;
withGroupRole?: boolean;
} = { withPermission: true; withOrgs: true; withGroupRole: false }
> = {
userId: string;
tmbId: string;
teamId: string;
memberName: string;
avatar: string;
role: `${TeamMemberRoleEnum}` | 'admin';
status: `${TeamMemberStatusEnum}`;
contact?: string;
createTime: Date;
updateTime?: Date;
} & (Options extends { withPermission: true }
? {
permission: TeamPermission;
}
: {}) &
(Options extends { withOrgs: true }
? {
orgs?: string[]; // full path name, pattern: /teamName/orgname1/orgname2
}
: {}) &
(Options extends { withGroupRole: true }
? {
groupRole?: `${GroupMemberRole}`;
}
: {});
export type TeamTagItemType = {
label: string;
key: string;
};
export type LafAccountType = {
appid: string;
token: string;
pat: string;
};
export type OpenaiAccountType = {
key: string;
baseUrl: string;
};
export type TeamInvoiceHeaderType = {
teamName: string;
unifiedCreditCode: string;
companyAddress?: string;
companyPhone?: string;
bankName?: string;
bankAccount?: string;
needSpecialInvoice: boolean;
contactPhone: string;
emailAddress: string;
};
export type TeamInvoiceHeaderInfoSchemaType = TeamInvoiceHeaderType & {
_id: string;
teamId: string;
};
import type { TeamPermission } from '../permission/user/controller';
import type { UserStatusEnum } from './constant';
import type { TeamMemberStatusEnum } from './team/constant';
import type { TeamTmbItemType } from './team/type';
export type UserModelSchema = {
_id: string;
username: string;
password: string;
promotionRate: number;
inviterId?: string;
openaiKey: string;
createTime: number;
timezone: string;
status: `${UserStatusEnum}`;
lastLoginTmbId?: string;
passwordUpdateTime?: Date;
fastgpt_sem?: {
keyword: string;
};
contact?: string;
};
export type UserType = {
_id: string;
username: string;
avatar: string; // it should be team member's avatar after 4.8.18
timezone: string;
promotionRate: UserModelSchema['promotionRate'];
team: TeamTmbItemType;
notificationAccount?: string;
permission: TeamPermission;
contact?: string;
};
export type SourceMemberType = {
name: string;
avatar: string;
status: `${TeamMemberStatusEnum}`;
};
export type InvoiceFileInfo = {
data: string; // base64 encoded file data
mimeType: string;
filename: string;
size: number;
};
import type { StandardSubLevelEnum, SubModeEnum } from '../sub/constants';
import { SubTypeEnum } from '../sub/constants';
import type { BillPayWayEnum, BillStatusEnum, BillTypeEnum } from './constants';
import type { TeamInvoiceHeaderType } from '../../user/team/type';
export type BillSchemaType = {
_id: string;
userId: string;
teamId: string;
tmbId: string;
createTime: Date;
orderId: string;
status: `${BillStatusEnum}`;
type: BillTypeEnum;
price: number;
hasInvoice: boolean;
metadata: {
payWay: `${BillPayWayEnum}`;
subMode?: `${SubModeEnum}`;
standSubLevel?: `${StandardSubLevelEnum}`;
month?: number;
datasetSize?: number;
extraPoints?: number;
};
refundData?: {
amount: number;
refundId: string;
refundTime: Date;
};
};
export type ChatNodeUsageType = {
inputTokens?: number;
outputTokens?: number;
totalPoints: number;
moduleName: string;
model?: string;
};
export type InvoiceType = {
amount: number;
billIdList: string[];
} & TeamInvoiceHeaderType;
export type InvoiceSchemaType = {
_id: string;
teamId: string;
status: 1 | 2;
createTime: Date;
finishTime?: Date;
file?: Buffer;
} & InvoiceType;
export type AIPointsPriceOption = {
type: 'points';
points: number;
};
export type DatasetPriceOption = {
type: 'dataset';
size: number;
month: number;
};
export type PriceOption = AIPointsPriceOption | DatasetPriceOption;
import type { StandardSubLevelEnum, SubModeEnum } from './constants';
import { TeamSubSchema } from './type.d';
export type StandardSubPlanParams = {
level: `${StandardSubLevelEnum}`;
mode: `${SubModeEnum}`;
};
export type StandardSubPlanUpdateResponse = {
balanceEnough: boolean; // team balance is enough
teamBalance: number;
payPrice?: number;
planPrice: number;
planPointPrice: number;
name?: string;
currentMode: `${SubModeEnum}`;
nextMode: `${SubModeEnum}`;
currentSubLevel: `${StandardSubLevelEnum}`;
nextSubLevel: `${StandardSubLevelEnum}`;
totalPoints: number;
surplusPoints: number;
planStartTime: Date;
planExpiredTime: Date;
};
import type { SubTypeEnum, StandardSubLevelEnum } from '../constants';
import type { CouponTypeEnum } from './constants';
export type TeamCouponSub = {
type: `${SubTypeEnum}`; // Sub type
durationDay: number; // Duration day
level?: `${StandardSubLevelEnum}`; // Standard sub level
extraDatasetSize?: number; // Extra dataset size
totalPoints?: number; // Total points(Extrapoints or Standard sub)
};
export type TeamCouponSchema = {
key: string;
subscriptions: TeamCouponSub[];
redeemedAt?: Date;
expiredAt?: Date;
redeemedTeamId?: string;
type: CouponTypeEnum;
price?: number;
description?: string;
};
import type { StandardSubLevelEnum, SubModeEnum, SubTypeEnum } from './constants';
// Content of plan
export type TeamStandardSubPlanItemType = {
name?: string;
price: number; // read price / month
pointPrice: number; // read price/ one thousand
totalPoints: number; // n
maxTeamMember: number;
maxAppAmount: number; // max app or plugin amount
maxDatasetAmount: number;
chatHistoryStoreDuration: number; // n day
maxDatasetSize: number;
trainingWeight: number; // 1~4
permissionCustomApiKey: boolean;
permissionCustomCopyright: boolean; // feature
permissionWebsiteSync: boolean;
permissionTeamOperationLog: boolean;
};
export type StandSubPlanLevelMapType = Record<
`${StandardSubLevelEnum}`,
TeamStandardSubPlanItemType
>;
export type SubPlanType = {
[SubTypeEnum.standard]: StandSubPlanLevelMapType;
planDescriptionUrl?: string;
[SubTypeEnum.extraDatasetSize]: {
price: number;
};
[SubTypeEnum.extraPoints]: {
price: number;
};
};
export type TeamSubSchema = {
_id: string;
teamId: string;
type: `${SubTypeEnum}`;
startTime: Date;
expiredTime: Date;
currentMode: `${SubModeEnum}`;
nextMode: `${SubModeEnum}`;
currentSubLevel: StandardSubLevelEnum;
nextSubLevel: StandardSubLevelEnum;
maxTeamMember?: number;
maxApp?: number;
maxDataset?: number;
totalPoints: number;
surplusPoints: number;
currentExtraDatasetSize: number;
};
export type TeamPlanStatusType = {
[SubTypeEnum.standard]?: TeamSubSchema;
standardConstants?: TeamStandardSubPlanItemType;
totalPoints: number;
usedPoints: number;
// standard + extra
datasetMaxSize: number;
};
export type ClientTeamPlanStatusType = TeamPlanStatusType & {
usedMember: number;
usedAppAmount: number;
usedDatasetSize: number;
usedDatasetIndexSize: number;
};
import type { UsageSourceEnum } from './constants';
import type { UsageListItemCountType, UsageListItemType } from './type';
export type CreateTrainingUsageProps = {
name: string;
datasetId: string;
};
export type GetUsageProps = {
dateStart: string;
dateEnd: string;
sources?: UsageSourceEnum[];
teamMemberIds?: string[];
projectName?: string;
};
export type GetUsageDashboardProps = GetUsageProps & {
unit: 'day' | 'month';
};
export type GetUsageDashboardResponseItem = {
date: Date;
totalPoints: number;
};
export type ConcatUsageProps = UsageListItemCountType & {
teamId: string;
tmbId: string;
billId?: string;
totalPoints: number;
listIndex?: number;
};
export type CreateUsageProps = {
teamId: string;
tmbId: string;
appName: string;
appId?: string;
pluginId?: string;
totalPoints: number;
source: `${UsageSourceEnum}`;
list: UsageListItemType[];
};
import type { SourceMemberType } from '../../../support/user/type';
import type { CreateUsageProps } from './api';
import { UsageSourceEnum } from './constants';
export type UsageListItemCountType = {
inputTokens?: number;
outputTokens?: number;
charsLength?: number;
duration?: number;
pages?: number;
count?: number; // Times
// deprecated
tokens?: number;
};
export type UsageListItemType = UsageListItemCountType & {
moduleName: string;
amount: number;
model?: string;
count?: number;
};
export type UsageSchemaType = CreateUsageProps & {
_id: string;
time: Date;
};
export type UsageItemType = {
id: string;
time: Date;
appName: string;
source: UsageSchemaType['source'];
totalPoints: number;
list: UsageSchemaType['list'];
sourceMember: SourceMemberType;
};
export type TTSBufferSchemaType = {
bufferId: string;
text: string;
buffer: Buffer;
};
export type FrequencyLimitSchemaType = {
_id: string;
eventId: string; // 事件ID
amount: number; // 当前数量
expiredTime: Date; // 什么时候过期,过期则重置
};
import type { LogLevelEnum } from './constant';
import { LogSignEnum } from './constant';
export type SystemLogType = {
_id: string;
text: string;
level: LogLevelEnum;
time: Date;
metadata?: Record<string, any>;
};
export type TimerLockSchemaType = {
_id: string;
timerId: string;
expiredTime: Date;
};
import type { EmbeddingRecallItemType } from './type';
export type DeleteDatasetVectorProps = (
| { id: string }
| { datasetIds: string[]; collectionIds?: string[] }
| { idList: string[] }
) & {
teamId: string;
};
export type DelDatasetVectorCtrlProps = DeleteDatasetVectorProps & {
retry?: number;
};
export type InsertVectorProps = {
teamId: string;
datasetId: string;
collectionId: string;
};
export type InsertVectorControllerProps = InsertVectorProps & {
vectors: number[][];
};
export type EmbeddingRecallProps = {
teamId: string;
datasetIds: string[];
forbidCollectionIdList: string[];
filterCollectionIdList?: string[];
};
export type EmbeddingRecallCtrlProps = EmbeddingRecallProps & {
vector: number[];
limit: number;
retry?: number;
};
export type EmbeddingRecallResponse = {
results: EmbeddingRecallItemType[];
};
import type { Pool } from 'pg';
import type { Pool as MysqlPool } from 'mysql2/promise';
import type { MilvusClient } from '@zilliz/milvus2-sdk-node';
declare global {
var pgClient: Pool | null;
var obClient: MysqlPool | null;
var milvusClient: MilvusClient | null;
}
export type EmbeddingRecallItemType = {
id: string;
collectionId: string;
score: number;
};
import type {
ChatCompletionMessageParam,
CompletionFinishReason
} from '@fastgpt/global/core/ai/llm/type';
import type { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
import type {
ModuleDispatchProps,
DispatchNodeResponseType
} from '@fastgpt/global/core/workflow/runtime/type';
import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type';
import { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
import type { DispatchFlowResponse } from '../../type';
import type { ChatItemType, AIChatItemValueItemType } from '@fastgpt/global/core/chat/type.d';
import { ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
import type { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
import type { WorkflowInteractiveResponseType } from '@fastgpt/global/core/workflow/template/system/interactive/type';
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.schema';
import type { JSONSchemaInputType } from '@fastgpt/global/core/app/jsonschema';
export type DispatchToolModuleProps = ModuleDispatchProps<{
[NodeInputKeyEnum.history]?: ChatItemType[];
[NodeInputKeyEnum.userChatInput]: string;
[NodeInputKeyEnum.fileUrlList]?: string[];
[NodeInputKeyEnum.aiModel]: string;
[NodeInputKeyEnum.aiSystemPrompt]: string;
[NodeInputKeyEnum.aiChatTemperature]: number;
[NodeInputKeyEnum.aiChatMaxToken]: number;
[NodeInputKeyEnum.aiChatVision]?: boolean;
[NodeInputKeyEnum.aiChatReasoning]?: boolean;
[NodeInputKeyEnum.aiChatTopP]?: number;
[NodeInputKeyEnum.aiChatStopSign]?: string;
[NodeInputKeyEnum.aiChatResponseFormat]?: string;
[NodeInputKeyEnum.aiChatJsonSchema]?: string;
}> & {
messages: ChatCompletionMessageParam[];
toolNodes: ToolNodeItemType[];
toolModel: LLMModelItemType;
interactiveEntryToolParams?: WorkflowInteractiveResponseType['toolParams'];
};
export type RunToolResponse = {
dispatchFlowResponse: DispatchFlowResponse[];
toolNodeInputTokens: number;
toolNodeOutputTokens: number;
completeMessages?: ChatCompletionMessageParam[];
assistantResponses?: AIChatItemValueItemType[];
toolWorkflowInteractiveResponse?: WorkflowInteractiveResponseType;
[DispatchNodeResponseKeyEnum.runTimes]: number;
finish_reason?: CompletionFinishReason;
};
export type ToolNodeItemType = RuntimeNodeItemType & {
toolParams: RuntimeNodeItemType['inputs'];
jsonSchema?: JSONSchemaInputType;
};
import type {
AIChatItemValueItemType,
ChatHistoryItemResType,
ToolRunResponseItemType
} from '@fastgpt/global/core/chat/type';
import { ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
import type {
DispatchNodeResponseKeyEnum,
SseResponseEventEnum
} from '@fastgpt/global/core/workflow/runtime/constants';
import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type';
import type { WorkflowInteractiveResponseType } from '@fastgpt/global/core/workflow/template/system/interactive/type';
import type { RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
import type { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
export type DispatchFlowResponse = {
flowResponses: ChatHistoryItemResType[];
flowUsages: ChatNodeUsageType[];
debugResponse: {
finishedNodes: RuntimeNodeItemType[];
finishedEdges: RuntimeEdgeItemType[];
nextStepRunNodes: RuntimeNodeItemType[];
};
workflowInteractiveResponse?: WorkflowInteractiveResponseType;
[DispatchNodeResponseKeyEnum.toolResponses]: ToolRunResponseItemType;
[DispatchNodeResponseKeyEnum.assistantResponses]: AIChatItemValueItemType[];
[DispatchNodeResponseKeyEnum.runTimes]: number;
[DispatchNodeResponseKeyEnum.memories]?: Record<string, any>;
[DispatchNodeResponseKeyEnum.newVariables]: Record<string, string>;
durationSeconds: number;
};
export type WorkflowResponseType = ({
write,
event,
data,
stream
}: {
write?: ((text: string) => void) | undefined;
event: SseResponseEventEnum;
data: Record<string, any>;
stream?: boolean | undefined;
}) => void;
import type { Permission } from '@fastgpt/global/support/permission/controller';
import type { ApiRequestProps } from '../../type/next';
import type { PermissionValueType } from '@fastgpt/global/support/permission/type';
import type { RequireAtLeastOne } from '@fastgpt/global/common/type/utils';
import type { AuthUserTypeEnum } from '@fastgpt/global/support/permission/constant';
export type ReqHeaderAuthType = {
cookie?: string;
token?: string;
apikey?: string; // abandon
rootkey?: string;
userid?: string;
authorization?: string;
};
type authModeType = {
req: ApiRequestProps;
authToken?: boolean;
authRoot?: boolean;
authApiKey?: boolean;
per?: PermissionValueType;
};
export type AuthModeType = RequireAtLeastOne<authModeType, 'authApiKey' | 'authRoot' | 'authToken'>;
export type AuthResponseType<T extends Permission = Permission> = {
userId: string;
teamId: string;
tmbId: string;
authType?: `${AuthUserTypeEnum}`;
appId?: string;
apikey?: string;
isRoot: boolean;
permission: T;
};
import type { iconPaths } from './constants';
export type IconNameType = keyof typeof iconPaths;
import type { ButtonProps } from '@chakra-ui/react';
type ListItemType = {
alias?: string;
label: string | React.ReactNode;
value: any;
children?: ListItemType[];
};
export type MultipleSelectProps = {
label?: string | React.ReactNode;
value?: any[];
placeholder?: string;
list: ListItemType[];
emptyTip?: string;
maxH?: number;
onSelect: (val: any[]) => void;
popDirection?: 'top' | 'bottom';
changeOnEverySelect?: boolean;
ButtonProps?: ButtonProps;
};
export type MultipleArraySelectProps = Omit<MultipleSelectProps, 'value'> & {
value?: any[][];
onSelect: (val: any[][]) => void;
};
import type { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
export type EditorVariablePickerType = {
key: string;
label: string;
required?: boolean;
icon?: string;
valueType?: WorkflowIOValueTypeEnum;
valueDesc?: string;
};
export type EditorVariableLabelPickerType = {
key: string;
label: string;
required?: boolean;
icon?: string;
valueType?: WorkflowIOValueTypeEnum;
parent: {
id: string;
label: string;
avatar?: string;
};
};
export type FormPropsType = Omit<BoxProps, 'onChange' | 'onBlur'>;
import 'i18next';
import type account_team from './zh-CN/account_team.json';
import type account from './zh-CN/account.json';
import type account_thirdParty from './zh-CN/account_thirdParty.json';
import type account_promotion from './zh-CN/account_promotion.json';
import type account_inform from './zh-CN/account_inform.json';
import type account_setting from './zh-CN/account_setting.json';
import type account_apikey from './zh-CN/account_apikey.json';
import type account_bill from './zh-CN/account_bill.json';
import type account_usage from './zh-CN/account_usage.json';
import type account_info from './zh-CN/account_info.json';
import type common from './zh-CN/common.json';
import type dataset from './zh-CN/dataset.json';
import type app from './zh-CN/app.json';
import type file from './zh-CN/file.json';
import type publish from './zh-CN/publish.json';
import type workflow from './zh-CN/workflow.json';
import type user from './zh-CN/user.json';
import type chat from './zh-CN/chat.json';
import type login from './zh-CN/login.json';
import type account_model from './zh-CN/account_model.json';
import type dashboard_mcp from './zh-CN/dashboard_mcp.json';
import type { I18N_NAMESPACES } from './constants';
export interface I18nNamespaces {
common: typeof common;
dataset: typeof dataset;
app: typeof app;
file: typeof file;
publish: typeof publish;
workflow: typeof workflow;
user: typeof user;
chat: typeof chat;
login: typeof login;
account_info: typeof account_info;
account_usage: typeof account_usage;
account_bill: typeof account_bill;
account_apikey: typeof account_apikey;
account_setting: typeof account_setting;
account_inform: typeof account_inform;
account_promotion: typeof account_promotion;
account: typeof account;
account_team: typeof account_team;
account_thirdParty: typeof account_thirdParty;
account_model: typeof account_model;
dashboard_mcp: typeof dashboard_mcp;
dashboard_evaluation: typeof dashboard_evaluation;
}
export type I18nNsType = (keyof I18nNamespaces)[];
export type ParseKeys<Ns extends keyof I18nNamespaces = keyof I18nNamespaces> = {
[K in Ns]: `${K}:${keyof I18nNamespaces[K] & string}`;
}[Ns];
export type I18nKeyFunction = {
<Key extends ParseKeys>(key: Key): Key;
};
declare module 'i18next' {
interface CustomTypeOptions {
returnNull: false;
defaultNS: I18N_NAMESPACES;
resources: I18nNamespaces;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment