mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
V4.6.5-alpha (#609)
This commit is contained in:
8
packages/global/core/chat/type.d.ts
vendored
8
packages/global/core/chat/type.d.ts
vendored
@@ -84,12 +84,14 @@ export type ChatHistoryItemType = HistoryItemType & {
|
||||
|
||||
/* ------- response data ------------ */
|
||||
export type moduleDispatchResType = {
|
||||
// common
|
||||
moduleLogo?: string;
|
||||
price?: number;
|
||||
runningTime?: number;
|
||||
tokens?: number;
|
||||
model?: string;
|
||||
query?: string;
|
||||
contextTotalLen?: number;
|
||||
|
||||
// chat
|
||||
temperature?: number;
|
||||
@@ -116,6 +118,12 @@ export type moduleDispatchResType = {
|
||||
|
||||
// plugin output
|
||||
pluginOutput?: Record<string, any>;
|
||||
|
||||
// text editor
|
||||
textOutput?: string;
|
||||
|
||||
// tf switch
|
||||
tfSwitchResult?: boolean;
|
||||
};
|
||||
|
||||
export type ChatHistoryItemResType = moduleDispatchResType & {
|
||||
|
13
packages/global/core/module/api.d.ts
vendored
13
packages/global/core/module/api.d.ts
vendored
@@ -1,3 +1,16 @@
|
||||
import { VectorModelItemType } from '../ai/model.d';
|
||||
|
||||
export type SelectedDatasetType = { datasetId: string; vectorModel: VectorModelItemType }[];
|
||||
|
||||
export type HttpBodyType<T = any> = {
|
||||
appId: string;
|
||||
chatId?: string;
|
||||
variables: Record<string, any>;
|
||||
data: T;
|
||||
};
|
||||
export type HttpQueryType = {
|
||||
appId: string;
|
||||
chatId?: string;
|
||||
variables: Record<string, any>;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
@@ -1,19 +1,17 @@
|
||||
export enum ModuleTemplateTypeEnum {
|
||||
userGuide = 'userGuide',
|
||||
systemInput = 'systemInput',
|
||||
tools = 'tools',
|
||||
textAnswer = 'textAnswer',
|
||||
dataset = 'dataset',
|
||||
functionCall = 'functionCall',
|
||||
externalCall = 'externalCall',
|
||||
|
||||
personalPlugin = 'personalPlugin',
|
||||
communityPlugin = 'communityPlugin',
|
||||
commercialPlugin = 'commercialPlugin',
|
||||
|
||||
other = 'other'
|
||||
}
|
||||
|
||||
export enum ModuleDataTypeEnum {
|
||||
export enum ModuleIOValueTypeEnum {
|
||||
string = 'string',
|
||||
number = 'number',
|
||||
boolean = 'boolean',
|
||||
@@ -44,6 +42,9 @@ export enum ModuleInputKeyEnum {
|
||||
aiModel = 'model',
|
||||
aiSystemPrompt = 'systemPrompt',
|
||||
description = 'description',
|
||||
anyInput = 'system_anyInput',
|
||||
textareaInput = 'system_textareaInput',
|
||||
addInputParam = 'system_addInputParam',
|
||||
|
||||
// history
|
||||
historyMaxAmount = 'maxContext',
|
||||
@@ -69,7 +70,10 @@ export enum ModuleInputKeyEnum {
|
||||
extractKeys = 'extractKeys',
|
||||
|
||||
// http
|
||||
httpUrl = 'url',
|
||||
httpReqUrl = 'system_httpReqUrl',
|
||||
httpHeader = 'system_httpHeader',
|
||||
httpMethod = 'system_httpMethod',
|
||||
abandon_httpUrl = 'url',
|
||||
|
||||
// app
|
||||
runAppSelectApp = 'app',
|
||||
@@ -87,6 +91,8 @@ export enum ModuleOutputKeyEnum {
|
||||
answerText = 'answerText', // answer module text key
|
||||
success = 'success',
|
||||
failed = 'failed',
|
||||
text = 'system_text',
|
||||
addOutputParam = 'system_addOutputParam',
|
||||
|
||||
// dataset
|
||||
datasetIsEmpty = 'isEmpty',
|
||||
@@ -94,7 +100,11 @@ export enum ModuleOutputKeyEnum {
|
||||
datasetQuoteQA = 'quoteQA',
|
||||
|
||||
// context extract
|
||||
contextExtractFields = 'fields'
|
||||
contextExtractFields = 'fields',
|
||||
|
||||
// tf switch
|
||||
resultTrue = 'system_resultTrue',
|
||||
resultFalse = 'system_resultFalse'
|
||||
}
|
||||
|
||||
export enum VariableInputEnum {
|
||||
@@ -102,3 +112,5 @@ export enum VariableInputEnum {
|
||||
textarea = 'textarea',
|
||||
select = 'select'
|
||||
}
|
||||
|
||||
export const DYNAMIC_INPUT_KEY = 'DYNAMIC_INPUT_KEY';
|
||||
|
@@ -2,32 +2,39 @@ export enum FlowNodeInputTypeEnum {
|
||||
systemInput = 'systemInput', // history, userChatInput, variableInput
|
||||
|
||||
input = 'input', // one line input
|
||||
textarea = 'textarea',
|
||||
numberInput = 'numberInput',
|
||||
select = 'select',
|
||||
slider = 'slider',
|
||||
custom = 'custom',
|
||||
target = 'target', // data input
|
||||
switch = 'switch',
|
||||
textarea = 'textarea',
|
||||
|
||||
addInputParam = 'addInputParam', // params input
|
||||
|
||||
selectApp = 'selectApp',
|
||||
|
||||
// chat special input
|
||||
aiSettings = 'aiSettings',
|
||||
|
||||
// model select
|
||||
// ai model select
|
||||
selectChatModel = 'selectChatModel',
|
||||
selectCQModel = 'selectCQModel',
|
||||
selectExtractModel = 'selectExtractModel',
|
||||
|
||||
// dataset special input
|
||||
selectDataset = 'selectDataset',
|
||||
selectDatasetParamsModal = 'selectDatasetParamsModal',
|
||||
|
||||
hidden = 'hidden'
|
||||
hidden = 'hidden',
|
||||
custom = 'custom'
|
||||
}
|
||||
|
||||
export enum FlowNodeOutputTypeEnum {
|
||||
answer = 'answer',
|
||||
source = 'source',
|
||||
hidden = 'hidden'
|
||||
hidden = 'hidden',
|
||||
|
||||
addOutputParam = 'addOutputParam'
|
||||
}
|
||||
|
||||
export enum FlowNodeTypeEnum {
|
||||
@@ -45,7 +52,10 @@ export enum FlowNodeTypeEnum {
|
||||
pluginModule = 'pluginModule',
|
||||
pluginInput = 'pluginInput',
|
||||
pluginOutput = 'pluginOutput',
|
||||
textEditor = 'textEditor',
|
||||
|
||||
// abandon
|
||||
variable = 'variable'
|
||||
}
|
||||
|
||||
export const EDGE_TYPE = 'smoothstep';
|
||||
|
66
packages/global/core/module/node/type.d.ts
vendored
66
packages/global/core/module/node/type.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
import { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from './constant';
|
||||
import { ModuleDataTypeEnum, ModuleInputKeyEnum, ModuleOutputKeyEnum } from '../constants';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum, ModuleOutputKeyEnum } from '../constants';
|
||||
import { SelectedDatasetType } from '../api';
|
||||
import { EditInputFieldMap, EditOutputFieldMap } from './type';
|
||||
|
||||
export type FlowNodeChangeProps = {
|
||||
moduleId: string;
|
||||
@@ -20,27 +21,34 @@ export type FlowNodeChangeProps = {
|
||||
};
|
||||
|
||||
export type FlowNodeInputItemType = {
|
||||
valueType?: `${ModuleIOValueTypeEnum}`; // data type
|
||||
type: `${FlowNodeInputTypeEnum}`; // Node Type. Decide on a render style
|
||||
key: `${ModuleInputKeyEnum}` | string;
|
||||
type: `${FlowNodeInputTypeEnum}`; // Decide on a render style
|
||||
value?: any;
|
||||
valueType?: `${ModuleDataTypeEnum}`; // data type
|
||||
label: string;
|
||||
description?: string;
|
||||
required?: boolean;
|
||||
|
||||
edit?: boolean; // Whether to allow editing
|
||||
connected?: boolean; // unConnected field will be deleted
|
||||
editField?: EditInputFieldMap;
|
||||
defaultEditField?: EditNodeFieldType;
|
||||
|
||||
connected?: boolean; // There are incoming data
|
||||
|
||||
showTargetInApp?: boolean;
|
||||
showTargetInPlugin?: boolean;
|
||||
|
||||
placeholder?: string; // input,textarea
|
||||
list?: { label: string; value: any }[]; // select
|
||||
step?: number; // slider max?: number;
|
||||
max?: number;
|
||||
min?: number;
|
||||
markList?: { label: string; value: any }[]; // slider
|
||||
hideInApp?: boolean;
|
||||
hideInPlugin?: boolean;
|
||||
|
||||
plusField?: boolean; // plus system will show
|
||||
placeholder?: string; // input,textarea
|
||||
|
||||
list?: { label: string; value: any }[]; // select
|
||||
|
||||
markList?: { label: string; value: any }[]; // slider
|
||||
step?: number; // slider
|
||||
max?: number; // slider, number input
|
||||
min?: number; // slider, number input
|
||||
};
|
||||
|
||||
export type FlowNodeOutputTargetItemType = {
|
||||
@@ -48,15 +56,41 @@ export type FlowNodeOutputTargetItemType = {
|
||||
key: string;
|
||||
};
|
||||
export type FlowNodeOutputItemType = {
|
||||
key: `${ModuleOutputKeyEnum}` | string;
|
||||
label?: string;
|
||||
edit?: boolean;
|
||||
description?: string;
|
||||
valueType?: `${ModuleDataTypeEnum}`;
|
||||
type?: `${FlowNodeOutputTypeEnum}`;
|
||||
key: `${ModuleOutputKeyEnum}` | string;
|
||||
valueType?: `${ModuleIOValueTypeEnum}`;
|
||||
|
||||
label?: string;
|
||||
description?: string;
|
||||
|
||||
edit?: boolean;
|
||||
editField?: EditOutputFieldMap;
|
||||
defaultEditField?: EditNodeFieldType;
|
||||
|
||||
targets: FlowNodeOutputTargetItemType[];
|
||||
};
|
||||
|
||||
/* --------------- edit field ------------------- */
|
||||
export type EditInputFieldMap = EditOutputFieldMap & {
|
||||
inputType?: boolean;
|
||||
required?: boolean;
|
||||
};
|
||||
export type EditOutputFieldMap = {
|
||||
name?: boolean;
|
||||
key?: boolean;
|
||||
description?: boolean;
|
||||
dataType?: boolean;
|
||||
};
|
||||
export type EditNodeFieldType = {
|
||||
inputType?: `${FlowNodeInputTypeEnum}`; // input type
|
||||
outputType?: `${FlowNodeOutputTypeEnum}`;
|
||||
required?: boolean;
|
||||
key?: string;
|
||||
label?: string;
|
||||
description?: string;
|
||||
valueType?: `${ModuleIOValueTypeEnum}`;
|
||||
};
|
||||
|
||||
/* ------------- item type --------------- */
|
||||
/* ai chat modules props */
|
||||
export type AIChatModuleProps = {
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import type { FlowNodeInputItemType } from '../node/type.d';
|
||||
import { ModuleInputKeyEnum } from '../constants';
|
||||
import { DYNAMIC_INPUT_KEY, ModuleInputKeyEnum } from '../constants';
|
||||
import { FlowNodeInputTypeEnum } from '../node/constant';
|
||||
import { ModuleDataTypeEnum } from '../constants';
|
||||
import { ModuleIOValueTypeEnum } from '../constants';
|
||||
|
||||
export const Input_Template_TFSwitch: FlowNodeInputItemType = {
|
||||
export const Input_Template_Switch: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.switch,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: 'core.module.input.label.switch',
|
||||
valueType: ModuleDataTypeEnum.any,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
};
|
||||
@@ -19,7 +19,7 @@ export const Input_Template_History: FlowNodeInputItemType = {
|
||||
required: true,
|
||||
min: 0,
|
||||
max: 30,
|
||||
valueType: ModuleDataTypeEnum.chatHistory,
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
value: 6,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
@@ -30,7 +30,29 @@ export const Input_Template_UserChatInput: FlowNodeInputItemType = {
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: 'core.module.input.label.user question',
|
||||
required: true,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
};
|
||||
|
||||
export const Input_Template_AddInputParam: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.addInputParam,
|
||||
type: FlowNodeInputTypeEnum.addInputParam,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '',
|
||||
required: false,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
};
|
||||
|
||||
export const Input_Template_DynamicInput: FlowNodeInputItemType = {
|
||||
key: DYNAMIC_INPUT_KEY,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: 'core.module.inputType.dynamicTargetInput',
|
||||
description: 'core.module.input.description.dynamic input',
|
||||
required: false,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: true,
|
||||
hideInApp: true
|
||||
};
|
||||
|
@@ -1,13 +1,21 @@
|
||||
import type { FlowNodeOutputItemType } from '../node/type';
|
||||
import { ModuleOutputKeyEnum } from '../constants';
|
||||
import { FlowNodeOutputTypeEnum } from '../node/constant';
|
||||
import { ModuleDataTypeEnum } from '../constants';
|
||||
import { ModuleIOValueTypeEnum } from '../constants';
|
||||
|
||||
export const Output_Template_Finish: FlowNodeOutputItemType = {
|
||||
key: ModuleOutputKeyEnum.finish,
|
||||
label: 'core.module.output.label.running done',
|
||||
description: 'core.module.output.description.running done',
|
||||
valueType: ModuleDataTypeEnum.boolean,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
};
|
||||
|
||||
export const Output_Template_AddOutput: FlowNodeOutputItemType = {
|
||||
key: ModuleOutputKeyEnum.addOutputParam,
|
||||
type: FlowNodeOutputTypeEnum.addOutputParam,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '',
|
||||
targets: []
|
||||
};
|
||||
|
@@ -2,9 +2,13 @@ import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import { ModuleDataTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
} from '../../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../../type';
|
||||
import {
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../../constants';
|
||||
|
||||
export const HistoryModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.historyNode,
|
||||
@@ -12,7 +16,7 @@ export const HistoryModule: FlowModuleTemplateType = {
|
||||
flowType: FlowNodeTypeEnum.historyNode,
|
||||
avatar: '/imgs/module/history.png',
|
||||
name: '聊天记录(弃用)',
|
||||
intro: '用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。',
|
||||
intro: '聊天记录,该模块已被弃用',
|
||||
inputs: [
|
||||
{
|
||||
key: ModuleInputKeyEnum.historyMaxAmount,
|
||||
@@ -21,7 +25,7 @@ export const HistoryModule: FlowModuleTemplateType = {
|
||||
description:
|
||||
'该记录数不代表模型可接收这么多的历史记录,具体可接收多少历史记录,取决于模型的能力,通常建议不要超过20条。',
|
||||
value: 6,
|
||||
valueType: ModuleDataTypeEnum.number,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 0,
|
||||
max: 100,
|
||||
showTargetInApp: false,
|
||||
@@ -30,7 +34,7 @@ export const HistoryModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.history,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleDataTypeEnum.chatHistory,
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
label: '聊天记录',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -40,7 +44,7 @@ export const HistoryModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.history,
|
||||
label: '聊天记录',
|
||||
valueType: ModuleDataTypeEnum.chatHistory,
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
}
|
@@ -5,14 +5,14 @@ import {
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import {
|
||||
ModuleDataTypeEnum,
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleOutputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import {
|
||||
Input_Template_History,
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
Input_Template_UserChatInput
|
||||
} from '../input';
|
||||
import { chatNodeSystemPromptTip } from '../tip';
|
||||
@@ -27,13 +27,13 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
intro: 'AI 大模型对话',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiModel,
|
||||
type: FlowNodeInputTypeEnum.selectChatModel,
|
||||
label: '对话模型',
|
||||
required: true,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -43,7 +43,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
type: FlowNodeInputTypeEnum.hidden, // Set in the pop-up window
|
||||
label: '温度',
|
||||
value: 0,
|
||||
valueType: ModuleDataTypeEnum.number,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 0,
|
||||
max: 10,
|
||||
step: 1,
|
||||
@@ -59,7 +59,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
type: FlowNodeInputTypeEnum.hidden, // Set in the pop-up window
|
||||
label: '回复上限',
|
||||
value: 2000,
|
||||
valueType: ModuleDataTypeEnum.number,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 100,
|
||||
max: 4000,
|
||||
step: 50,
|
||||
@@ -78,7 +78,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '返回AI内容',
|
||||
value: true,
|
||||
valueType: ModuleDataTypeEnum.boolean,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -86,7 +86,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.aiChatQuoteTemplate,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '引用内容模板',
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -94,7 +94,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.aiChatQuotePrompt,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '引用内容提示词',
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -102,7 +102,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.aiChatSettingModal,
|
||||
type: FlowNodeInputTypeEnum.aiSettings,
|
||||
label: '',
|
||||
valueType: ModuleDataTypeEnum.any,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -112,7 +112,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
label: '系统提示词',
|
||||
max: 300,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
description: chatNodeSystemPromptTip,
|
||||
placeholder: chatNodeSystemPromptTip,
|
||||
showTargetInApp: true,
|
||||
@@ -124,7 +124,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '引用内容',
|
||||
description: "对象数组格式,结构:\n [{q:'问题',a:'回答'}]",
|
||||
valueType: ModuleDataTypeEnum.datasetQuote,
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
},
|
||||
@@ -135,7 +135,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
key: ModuleOutputKeyEnum.history,
|
||||
label: '新的上下文',
|
||||
description: '将本次回复内容拼接上历史记录,作为新的上下文返回',
|
||||
valueType: ModuleDataTypeEnum.chatHistory,
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
},
|
||||
@@ -143,7 +143,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
key: ModuleOutputKeyEnum.answerText,
|
||||
label: 'AI回复',
|
||||
description: '将在 stream 回复完毕后触发',
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
},
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import { ModuleDataTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
import { Input_Template_TFSwitch } from '../input';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
import { Input_Template_Switch } from '../input';
|
||||
import { Output_Template_Finish } from '../output';
|
||||
|
||||
export const AssignedAnswerModule: FlowModuleTemplateType = {
|
||||
@@ -12,14 +12,16 @@ export const AssignedAnswerModule: FlowModuleTemplateType = {
|
||||
name: '指定回复',
|
||||
intro: '该模块可以直接回复一段指定的内容。常用于引导、提示',
|
||||
inputs: [
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.answerText,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
valueType: ModuleDataTypeEnum.any,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '回复的内容',
|
||||
description:
|
||||
'可以使用 \\n 来实现连续换行。\n\n可以通过外部模块输入实现回复,外部模块输入时会覆盖当前填写的内容。\n\n如传入非字符串类型数据将会自动转成字符串',
|
||||
'可以使用 \\n 来实现连续换行。\n可以通过外部模块输入实现回复,外部模块输入时会覆盖当前填写的内容。\n如传入非字符串类型数据将会自动转成字符串',
|
||||
placeholder:
|
||||
'可以使用 \\n 来实现连续换行。\n可以通过外部模块输入实现回复,外部模块输入时会覆盖当前填写的内容。\n如传入非字符串类型数据将会自动转成字符串',
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
}
|
||||
|
@@ -4,10 +4,10 @@ import {
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import { ModuleDataTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
import {
|
||||
Input_Template_History,
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
Input_Template_UserChatInput
|
||||
} from '../input';
|
||||
|
||||
@@ -24,11 +24,11 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
|
||||
类型4: 其他问题`,
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiModel,
|
||||
type: FlowNodeInputTypeEnum.selectCQModel,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '分类模型',
|
||||
required: true,
|
||||
showTargetInApp: false,
|
||||
@@ -37,7 +37,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiSystemPrompt,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '背景知识',
|
||||
description:
|
||||
'你可以添加一些特定内容的介绍,从而更好的识别用户的问题类型。这个内容通常是给模型介绍一个它不知道的内容。',
|
||||
@@ -51,7 +51,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.agents,
|
||||
type: FlowNodeInputTypeEnum.custom,
|
||||
valueType: ModuleDataTypeEnum.any,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '',
|
||||
value: [
|
||||
{
|
||||
|
@@ -5,12 +5,12 @@ import {
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import {
|
||||
ModuleDataTypeEnum,
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleOutputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import { Input_Template_History, Input_Template_TFSwitch } from '../input';
|
||||
import { Input_Template_History, Input_Template_Switch } from '../input';
|
||||
|
||||
export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.contentExtract,
|
||||
@@ -21,11 +21,20 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
intro: '可从文本中提取指定的数据,例如:sql语句、搜索关键词、代码等',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiModel,
|
||||
type: FlowNodeInputTypeEnum.selectExtractModel,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '提取模型',
|
||||
required: true,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.description,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '提取要求描述',
|
||||
description: '给AI一些对应的背景知识或要求描述,引导AI更好的完成任务',
|
||||
required: true,
|
||||
@@ -40,7 +49,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '需要提取的文本',
|
||||
required: true,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
},
|
||||
@@ -48,9 +57,9 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.extractKeys,
|
||||
type: FlowNodeInputTypeEnum.custom,
|
||||
label: '目标字段',
|
||||
valueType: ModuleDataTypeEnum.any,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
description: "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段",
|
||||
value: [], // {desc: string; key: string; required: boolean;}[]
|
||||
value: [], // {desc: string; key: string; required: boolean; enum: string[]}[]
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
}
|
||||
@@ -59,14 +68,14 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleOutputKeyEnum.success,
|
||||
label: '字段完全提取',
|
||||
valueType: ModuleDataTypeEnum.boolean,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
key: ModuleOutputKeyEnum.failed,
|
||||
label: '提取字段缺失',
|
||||
valueType: ModuleDataTypeEnum.boolean,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
},
|
||||
@@ -74,7 +83,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
key: ModuleOutputKeyEnum.contextExtractFields,
|
||||
label: '完整提取结果',
|
||||
description: '一个 JSON 字符串,例如:{"name:":"YY","Time":"2023/7/2 18:00"}',
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
}
|
||||
|
@@ -5,31 +5,31 @@ import {
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import {
|
||||
ModuleDataTypeEnum,
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleOutputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import { Input_Template_TFSwitch, Input_Template_UserChatInput } from '../input';
|
||||
import { Input_Template_Switch, Input_Template_UserChatInput } from '../input';
|
||||
import { Output_Template_Finish } from '../output';
|
||||
import { DatasetSearchModeEnum } from '../../../dataset/constant';
|
||||
|
||||
export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.datasetSearchNode,
|
||||
templateType: ModuleTemplateTypeEnum.dataset,
|
||||
templateType: ModuleTemplateTypeEnum.functionCall,
|
||||
flowType: FlowNodeTypeEnum.datasetSearchNode,
|
||||
avatar: '/imgs/module/db.png',
|
||||
name: '知识库搜索',
|
||||
intro: '去知识库中搜索对应的答案。可作为 AI 对话引用参考。',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.datasetSelectList,
|
||||
type: FlowNodeInputTypeEnum.selectDataset,
|
||||
label: '关联的知识库',
|
||||
value: [],
|
||||
valueType: ModuleDataTypeEnum.selectDataset,
|
||||
valueType: ModuleIOValueTypeEnum.selectDataset,
|
||||
list: [],
|
||||
required: true,
|
||||
showTargetInApp: false,
|
||||
@@ -40,7 +40,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '最低相关性',
|
||||
value: 0.4,
|
||||
valueType: ModuleDataTypeEnum.number,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
@@ -57,7 +57,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
label: '引用上限',
|
||||
description: '单次搜索最大的 Tokens 数量,中文约1字=1.7Tokens,英文约1字=1Tokens',
|
||||
value: 1500,
|
||||
valueType: ModuleDataTypeEnum.number,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -65,7 +65,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.datasetSearchMode,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: 'core.dataset.search.Mode',
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false,
|
||||
value: DatasetSearchModeEnum.embedding
|
||||
@@ -74,7 +74,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.datasetParamsModal,
|
||||
type: FlowNodeInputTypeEnum.selectDatasetParamsModal,
|
||||
label: '',
|
||||
valueType: ModuleDataTypeEnum.any,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -85,14 +85,14 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
key: ModuleOutputKeyEnum.datasetIsEmpty,
|
||||
label: '搜索结果为空',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleDataTypeEnum.boolean,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
key: ModuleOutputKeyEnum.datasetUnEmpty,
|
||||
label: '搜索结果不为空',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleDataTypeEnum.boolean,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
@@ -101,7 +101,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
description:
|
||||
'始终返回数组,如果希望搜索结果为空时执行额外操作,需要用到上面的两个输入以及目标模块的触发器',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleDataTypeEnum.datasetQuote,
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
targets: []
|
||||
},
|
||||
Output_Template_Finish
|
||||
|
@@ -1,8 +1,16 @@
|
||||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import { ModuleDataTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
import { Input_Template_TFSwitch } from '../input';
|
||||
import { Output_Template_Finish } from '../output';
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
import {
|
||||
Input_Template_AddInputParam,
|
||||
Input_Template_DynamicInput,
|
||||
Input_Template_Switch
|
||||
} from '../input';
|
||||
import { Output_Template_AddOutput, Output_Template_Finish } from '../output';
|
||||
|
||||
export const HttpModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.httpRequest,
|
||||
@@ -13,18 +21,86 @@ export const HttpModule: FlowModuleTemplateType = {
|
||||
intro: '可以发出一个 HTTP POST 请求,实现更为复杂的操作(联网搜索、数据库查询等)',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.httpUrl,
|
||||
type: FlowNodeInputTypeEnum.input,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
label: '请求地址',
|
||||
description: '请求目标地址',
|
||||
placeholder: 'https://api.ai.com/getInventory',
|
||||
key: ModuleInputKeyEnum.httpMethod,
|
||||
type: FlowNodeInputTypeEnum.select,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: 'core.module.input.label.Http Request Method',
|
||||
value: 'POST',
|
||||
list: [
|
||||
{
|
||||
label: 'GET',
|
||||
value: 'GET'
|
||||
},
|
||||
{
|
||||
label: 'POST',
|
||||
value: 'POST'
|
||||
}
|
||||
],
|
||||
required: true,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.httpReqUrl,
|
||||
type: FlowNodeInputTypeEnum.input,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: 'core.module.input.label.Http Request Url',
|
||||
description: 'core.module.input.description.Http Request Url',
|
||||
placeholder: 'https://api.ai.com/getInventory',
|
||||
required: false,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.httpHeader,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: 'core.module.input.label.Http Request Header',
|
||||
description: 'core.module.input.description.Http Request Header',
|
||||
placeholder: 'core.module.input.description.Http Request Header',
|
||||
required: false,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
Input_Template_DynamicInput,
|
||||
{
|
||||
...Input_Template_AddInputParam,
|
||||
editField: {
|
||||
key: true,
|
||||
name: true,
|
||||
description: true,
|
||||
required: true,
|
||||
dataType: true
|
||||
},
|
||||
defaultEditField: {
|
||||
label: '',
|
||||
key: '',
|
||||
description: '',
|
||||
inputType: FlowNodeInputTypeEnum.target,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
],
|
||||
outputs: [Output_Template_Finish]
|
||||
outputs: [
|
||||
Output_Template_Finish,
|
||||
{
|
||||
...Output_Template_AddOutput,
|
||||
editField: {
|
||||
key: true,
|
||||
name: true,
|
||||
description: true,
|
||||
dataType: true
|
||||
},
|
||||
defaultEditField: {
|
||||
label: '',
|
||||
key: '',
|
||||
description: '',
|
||||
outputType: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.string
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@@ -5,14 +5,14 @@ import {
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import {
|
||||
ModuleDataTypeEnum,
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleOutputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import {
|
||||
Input_Template_History,
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
Input_Template_UserChatInput
|
||||
} from '../input';
|
||||
import { Output_Template_Finish } from '../output';
|
||||
@@ -26,11 +26,11 @@ export const RunAppModule: FlowModuleTemplateType = {
|
||||
intro: '可以选择一个其他应用进行调用',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_TFSwitch,
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.runAppSelectApp,
|
||||
type: FlowNodeInputTypeEnum.selectApp,
|
||||
valueType: ModuleDataTypeEnum.selectApp,
|
||||
valueType: ModuleIOValueTypeEnum.selectApp,
|
||||
label: '选择一个应用',
|
||||
description: '选择一个其他应用进行调用',
|
||||
required: true,
|
||||
@@ -45,7 +45,7 @@ export const RunAppModule: FlowModuleTemplateType = {
|
||||
key: ModuleOutputKeyEnum.history,
|
||||
label: '新的上下文',
|
||||
description: '将该应用回复内容拼接到历史记录中,作为新的上下文返回',
|
||||
valueType: ModuleDataTypeEnum.chatHistory,
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
},
|
||||
@@ -53,7 +53,7 @@ export const RunAppModule: FlowModuleTemplateType = {
|
||||
key: ModuleOutputKeyEnum.answerText,
|
||||
label: 'AI回复',
|
||||
description: '将在应用完全结束后触发',
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
},
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import { userGuideTip } from '../tip';
|
||||
import { ModuleDataTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum, ModuleTemplateTypeEnum } from '../../constants';
|
||||
|
||||
export const UserGuideModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.userGuide,
|
||||
@@ -14,7 +14,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.welcomeText,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '开场白',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -22,7 +22,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.variables,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleDataTypeEnum.any,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '对话框变量',
|
||||
value: [],
|
||||
showTargetInApp: false,
|
||||
@@ -30,7 +30,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.questionGuide,
|
||||
valueType: ModuleDataTypeEnum.boolean,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
type: FlowNodeInputTypeEnum.switch,
|
||||
label: '问题引导',
|
||||
showTargetInApp: false,
|
||||
@@ -39,7 +39,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.tts,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleDataTypeEnum.any,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '语音播报',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
|
@@ -5,7 +5,7 @@ import {
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import {
|
||||
ModuleDataTypeEnum,
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleOutputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
@@ -22,7 +22,7 @@ export const UserInputModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.userChatInput,
|
||||
type: FlowNodeInputTypeEnum.systemInput,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '用户问题',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -33,7 +33,7 @@ export const UserInputModule: FlowModuleTemplateType = {
|
||||
key: ModuleOutputKeyEnum.userChatInput,
|
||||
label: '用户问题',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
targets: []
|
||||
}
|
||||
]
|
||||
|
3
packages/global/core/module/type.d.ts
vendored
3
packages/global/core/module/type.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { FlowNodeTypeEnum } from './node/constant';
|
||||
import { ModuleDataTypeEnum, ModuleTemplateTypeEnum, VariableInputEnum } from './constants';
|
||||
import { ModuleIOValueTypeEnum, ModuleTemplateTypeEnum, VariableInputEnum } from './constants';
|
||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
|
||||
|
||||
export type FlowModuleTemplateType = {
|
||||
@@ -72,4 +72,5 @@ export type ContextExtractAgentItemType = {
|
||||
desc: string;
|
||||
key: string;
|
||||
required: boolean;
|
||||
enum?: string;
|
||||
};
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from './node/constant';
|
||||
import { ModuleDataTypeEnum, ModuleInputKeyEnum } from './constants';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum } from './constants';
|
||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
|
||||
import { AppTTSConfigType, ModuleItemType, VariableItemType } from './type';
|
||||
import { Input_Template_Switch } from './template/input';
|
||||
|
||||
export const getGuideModule = (modules: ModuleItemType[]) =>
|
||||
modules.find((item) => item.flowType === FlowNodeTypeEnum.userGuide);
|
||||
@@ -29,42 +30,64 @@ export const splitGuideModule = (guideModules?: ModuleItemType) => {
|
||||
};
|
||||
};
|
||||
|
||||
export function formatPluginToPreviewModule(
|
||||
export const getOrInitModuleInputValue = (input: FlowNodeInputItemType) => {
|
||||
if (input.value !== undefined || !input.valueType) return input.value;
|
||||
|
||||
const map: Record<string, any> = {
|
||||
[ModuleIOValueTypeEnum.boolean]: false,
|
||||
[ModuleIOValueTypeEnum.number]: 0,
|
||||
[ModuleIOValueTypeEnum.string]: ''
|
||||
};
|
||||
|
||||
return map[input.valueType];
|
||||
};
|
||||
|
||||
export const getModuleInputUiField = (input: FlowNodeInputItemType) => {
|
||||
if (input.type === FlowNodeInputTypeEnum.input || input.type === FlowNodeInputTypeEnum.textarea) {
|
||||
return {
|
||||
placeholder: input.placeholder || input.description
|
||||
};
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
||||
export function plugin2ModuleIO(
|
||||
pluginId: string,
|
||||
modules: ModuleItemType[]
|
||||
): {
|
||||
inputs: FlowNodeInputItemType[];
|
||||
outputs: FlowNodeOutputItemType[];
|
||||
} {
|
||||
function getPluginTemplatePluginIdInput(pluginId: string): FlowNodeInputItemType {
|
||||
return {
|
||||
key: ModuleInputKeyEnum.pluginId,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: 'pluginId',
|
||||
value: pluginId,
|
||||
valueType: ModuleDataTypeEnum.string,
|
||||
connected: true,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
};
|
||||
}
|
||||
|
||||
const pluginInput = modules.find((module) => module.flowType === FlowNodeTypeEnum.pluginInput);
|
||||
const customOutput = modules.find((module) => module.flowType === FlowNodeTypeEnum.pluginOutput);
|
||||
const pluginOutput = modules.find((module) => module.flowType === FlowNodeTypeEnum.pluginOutput);
|
||||
|
||||
return {
|
||||
inputs: pluginInput
|
||||
? [
|
||||
getPluginTemplatePluginIdInput(pluginId),
|
||||
{
|
||||
// plugin id
|
||||
key: ModuleInputKeyEnum.pluginId,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: 'pluginId',
|
||||
value: pluginId,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
connected: true,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
// switch
|
||||
Input_Template_Switch,
|
||||
...pluginInput.inputs.map((item) => ({
|
||||
...item,
|
||||
...getModuleInputUiField(item),
|
||||
value: getOrInitModuleInputValue(item),
|
||||
edit: false,
|
||||
connected: false
|
||||
}))
|
||||
]
|
||||
: [],
|
||||
outputs: customOutput
|
||||
? customOutput.outputs.map((item) => ({
|
||||
outputs: pluginOutput
|
||||
? pluginOutput.outputs.map((item) => ({
|
||||
...item,
|
||||
edit: false
|
||||
}))
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import { ModuleTemplateTypeEnum } from '../module/constants';
|
||||
import { ModuleItemType } from '../module/type';
|
||||
|
||||
export const defaultModules: ModuleItemType[] = [
|
||||
@@ -28,13 +27,8 @@ export const defaultModules: ModuleItemType[] = [
|
||||
}
|
||||
];
|
||||
|
||||
export enum PluginTypeEnum {
|
||||
export enum PluginSourceEnum {
|
||||
personal = 'personal',
|
||||
community = 'community',
|
||||
commercial = 'commercial'
|
||||
}
|
||||
export const PluginType2TemplateTypeMap = {
|
||||
[PluginTypeEnum.personal]: ModuleTemplateTypeEnum.personalPlugin,
|
||||
[PluginTypeEnum.community]: ModuleTemplateTypeEnum.communityPlugin,
|
||||
[PluginTypeEnum.commercial]: ModuleTemplateTypeEnum.commercialPlugin
|
||||
};
|
||||
|
9
packages/global/core/plugin/type.d.ts
vendored
9
packages/global/core/plugin/type.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
import { ModuleTemplateTypeEnum } from 'core/module/constants';
|
||||
import type { ModuleItemType } from '../module/type.d';
|
||||
import { PluginTypeEnum } from './constants';
|
||||
import type { FlowModuleTemplateType, ModuleItemType } from '../module/type.d';
|
||||
import { PluginSourceEnum } from './constants';
|
||||
|
||||
export type PluginItemSchema = {
|
||||
_id: string;
|
||||
@@ -16,11 +16,12 @@ export type PluginItemSchema = {
|
||||
|
||||
/* plugin template */
|
||||
export type PluginTemplateType = {
|
||||
author?: string;
|
||||
id: string;
|
||||
type: `${PluginTypeEnum}`;
|
||||
source: `${PluginSourceEnum}`;
|
||||
templateType: FlowModuleTemplateType['templateType'];
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
modules: ModuleItemType[];
|
||||
templateType?: `${ModuleTemplateTypeEnum}`;
|
||||
};
|
||||
|
8
packages/plugins/package.json
Normal file
8
packages/plugins/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "@fastgpt/plugins",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.8.5"
|
||||
}
|
||||
}
|
21
packages/plugins/tsconfig.json
Normal file
21
packages/plugins/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2015",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.d.ts", "../**/*.d.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
@@ -10,7 +10,7 @@ export async function createQuestionGuide({
|
||||
messages: ChatMessageItemType[];
|
||||
model: string;
|
||||
}) {
|
||||
const ai = getAIApi(undefined, 48000);
|
||||
const ai = getAIApi(undefined, 480000);
|
||||
const data = await ai.chat.completions.create({
|
||||
model: model,
|
||||
temperature: 0,
|
||||
|
@@ -1,9 +1,10 @@
|
||||
import { MongoPlugin } from './schema';
|
||||
import { FlowModuleTemplateType } from '@fastgpt/global/core/module/type';
|
||||
import { FlowNodeTypeEnum } from '@fastgpt/global/core/module/node/constant';
|
||||
import { formatPluginToPreviewModule } from '@fastgpt/global/core/module/utils';
|
||||
import { PluginType2TemplateTypeMap, PluginTypeEnum } from '@fastgpt/global/core/plugin/constants';
|
||||
import { plugin2ModuleIO } from '@fastgpt/global/core/module/utils';
|
||||
import { PluginSourceEnum } from '@fastgpt/global/core/plugin/constants';
|
||||
import type { PluginTemplateType } from '@fastgpt/global/core/plugin/type.d';
|
||||
import { ModuleTemplateTypeEnum } from '@fastgpt/global/core/module/constants';
|
||||
|
||||
/*
|
||||
plugin id rule:
|
||||
@@ -14,84 +15,71 @@ import type { PluginTemplateType } from '@fastgpt/global/core/plugin/type.d';
|
||||
|
||||
export async function splitCombinePluginId(id: string) {
|
||||
const splitRes = id.split('-');
|
||||
if (splitRes.length === 1 && id.length === 24) {
|
||||
if (splitRes.length === 1) {
|
||||
return {
|
||||
type: PluginTypeEnum.personal,
|
||||
source: PluginSourceEnum.personal,
|
||||
pluginId: id
|
||||
};
|
||||
}
|
||||
|
||||
const [type, pluginId] = id.split('-') as [`${PluginTypeEnum}`, string];
|
||||
if (!type || !pluginId) return Promise.reject('pluginId not found');
|
||||
const [source, pluginId] = id.split('-') as [`${PluginSourceEnum}`, string];
|
||||
if (!source || !pluginId) return Promise.reject('pluginId not found');
|
||||
|
||||
return { type, pluginId: id };
|
||||
return { source, pluginId: id };
|
||||
}
|
||||
|
||||
const getPluginTemplateById = async (id: string): Promise<PluginTemplateType> => {
|
||||
const { source, pluginId } = await splitCombinePluginId(id);
|
||||
if (source === PluginSourceEnum.community) {
|
||||
const item = global.communityPlugins?.find((plugin) => plugin.id === pluginId);
|
||||
if (!item) return Promise.reject('plugin not found');
|
||||
|
||||
return item;
|
||||
}
|
||||
if (source === PluginSourceEnum.personal) {
|
||||
const item = await MongoPlugin.findById(id).lean();
|
||||
if (!item) return Promise.reject('plugin not found');
|
||||
return {
|
||||
id: String(item._id),
|
||||
name: item.name,
|
||||
avatar: item.avatar,
|
||||
intro: item.intro,
|
||||
source: PluginSourceEnum.personal,
|
||||
modules: item.modules,
|
||||
templateType: ModuleTemplateTypeEnum.personalPlugin
|
||||
};
|
||||
}
|
||||
return Promise.reject('plugin not found');
|
||||
};
|
||||
|
||||
/* format plugin modules to plugin preview module */
|
||||
export async function getPluginPreviewModule({
|
||||
id
|
||||
}: {
|
||||
id: string;
|
||||
}): Promise<FlowModuleTemplateType> {
|
||||
// classify
|
||||
const { type, pluginId } = await splitCombinePluginId(id);
|
||||
const plugin = await getPluginTemplateById(id);
|
||||
|
||||
const plugin = await (async () => {
|
||||
if (type === PluginTypeEnum.community) {
|
||||
return global.communityPlugins?.find((plugin) => plugin.id === pluginId);
|
||||
}
|
||||
if (type === PluginTypeEnum.personal) {
|
||||
const item = await MongoPlugin.findById(id);
|
||||
if (!item) return undefined;
|
||||
return {
|
||||
id: String(item._id),
|
||||
name: item.name,
|
||||
avatar: item.avatar,
|
||||
intro: item.intro,
|
||||
type: PluginTypeEnum.personal,
|
||||
modules: item.modules
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
if (!plugin) return Promise.reject('plugin not found');
|
||||
return {
|
||||
id: plugin.id,
|
||||
templateType: PluginType2TemplateTypeMap[plugin.type],
|
||||
templateType: plugin.templateType,
|
||||
flowType: FlowNodeTypeEnum.pluginModule,
|
||||
avatar: plugin.avatar,
|
||||
name: plugin.name,
|
||||
intro: plugin.intro,
|
||||
showStatus: true,
|
||||
...formatPluginToPreviewModule(plugin.id, plugin.modules)
|
||||
...plugin2ModuleIO(plugin.id, plugin.modules)
|
||||
};
|
||||
}
|
||||
|
||||
/* run plugin time */
|
||||
export async function getPluginRuntimeById(id: string): Promise<PluginTemplateType> {
|
||||
const { type, pluginId } = await splitCombinePluginId(id);
|
||||
|
||||
const plugin = await (async () => {
|
||||
if (type === PluginTypeEnum.community) {
|
||||
return global.communityPlugins?.find((plugin) => plugin.id === pluginId);
|
||||
}
|
||||
if (type === PluginTypeEnum.personal) {
|
||||
const item = await MongoPlugin.findById(id);
|
||||
if (!item) return undefined;
|
||||
return {
|
||||
id: String(item._id),
|
||||
name: item.name,
|
||||
avatar: item.avatar,
|
||||
intro: item.intro,
|
||||
type: PluginTypeEnum.personal,
|
||||
modules: item.modules
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
if (!plugin) return Promise.reject('plugin not found');
|
||||
const plugin = await getPluginTemplateById(id);
|
||||
|
||||
return {
|
||||
id: plugin.id,
|
||||
type: plugin.type,
|
||||
source: plugin.source,
|
||||
templateType: plugin.templateType,
|
||||
name: plugin.name,
|
||||
avatar: plugin.avatar,
|
||||
intro: plugin.intro,
|
||||
|
@@ -7,7 +7,7 @@ import { MongoPlugin } from '../../../core/plugin/schema';
|
||||
import { PluginErrEnum } from '@fastgpt/global/common/error/code/plugin';
|
||||
import { PluginItemSchema } from '@fastgpt/global/core/plugin/type';
|
||||
import { splitCombinePluginId } from '../../../core/plugin/controller';
|
||||
import { PluginTypeEnum } from '@fastgpt/global/core/plugin/constants';
|
||||
import { PluginSourceEnum } from '@fastgpt/global/core/plugin/constants';
|
||||
|
||||
export async function authPluginCrud({
|
||||
id,
|
||||
@@ -66,13 +66,13 @@ export async function authPluginCanUse({
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
}) {
|
||||
const { type, pluginId } = await splitCombinePluginId(id);
|
||||
const { source, pluginId } = await splitCombinePluginId(id);
|
||||
|
||||
if (type === PluginTypeEnum.community) {
|
||||
if (source === PluginSourceEnum.community) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type === PluginTypeEnum.personal) {
|
||||
if (source === PluginSourceEnum.personal) {
|
||||
const { role } = await getTeamInfoByTmbId({ tmbId });
|
||||
const plugin = await MongoPlugin.findOne({ _id: pluginId, teamId });
|
||||
if (!plugin) {
|
||||
|
Reference in New Issue
Block a user