This commit is contained in:
Archer
2023-10-30 13:26:42 +08:00
committed by GitHub
parent 008d0af010
commit 60ee160131
216 changed files with 4429 additions and 2229 deletions

View File

@@ -1,14 +1,14 @@
import { AppTypeEnum, SystemInputEnum } from '../app';
import { TaskResponseKeyEnum } from '../chat';
import {
FlowModuleTypeEnum,
FlowInputItemTypeEnum,
FlowOutputItemTypeEnum,
SpecialInputKeyEnum,
FlowValueTypeEnum
} from './index';
FlowNodeTypeEnum,
FlowNodeInputTypeEnum,
FlowNodeOutputTypeEnum,
FlowNodeSpecialInputKeyEnum,
FlowNodeValTypeEnum
} from '@fastgpt/global/core/module/node/constant';
import type { AppItemType } from '@/types/app';
import type { FlowModuleTemplateType } from '@/types/core/app/flow';
import type { FlowModuleTemplateType } from '@fastgpt/global/core/module/type';
import { chatModelList, cqModelList } from '@/web/common/system/staticData';
import {
Input_Template_History,
@@ -30,7 +30,8 @@ export const variableTip =
export const questionGuideTip = `对话结束后,会为生成 3 个引导性问题。`;
export const VariableModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.variable,
id: FlowNodeTypeEnum.variable,
flowType: FlowNodeTypeEnum.variable,
logo: '/imgs/module/variable.png',
name: '全局变量',
intro: variableTip,
@@ -39,7 +40,7 @@ export const VariableModule: FlowModuleTemplateType = {
inputs: [
{
key: SystemInputEnum.variables,
type: FlowInputItemTypeEnum.systemInput,
type: FlowNodeInputTypeEnum.systemInput,
label: '变量输入',
value: []
}
@@ -47,39 +48,41 @@ export const VariableModule: FlowModuleTemplateType = {
outputs: []
};
export const UserGuideModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.userGuide,
id: FlowNodeTypeEnum.userGuide,
flowType: FlowNodeTypeEnum.userGuide,
logo: '/imgs/module/userGuide.png',
name: '用户引导',
intro: userGuideTip,
inputs: [
{
key: SystemInputEnum.welcomeText,
type: FlowInputItemTypeEnum.hidden,
type: FlowNodeInputTypeEnum.hidden,
label: '开场白'
},
{
key: SystemInputEnum.variables,
type: FlowInputItemTypeEnum.hidden,
type: FlowNodeInputTypeEnum.hidden,
label: '对话框变量',
value: []
},
{
key: SystemInputEnum.questionGuide,
type: FlowInputItemTypeEnum.switch,
type: FlowNodeInputTypeEnum.switch,
label: '问题引导'
}
],
outputs: []
};
export const UserInputModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.questionInput,
id: FlowNodeTypeEnum.questionInput,
flowType: FlowNodeTypeEnum.questionInput,
logo: '/imgs/module/userChatInput.png',
name: '用户问题(对话入口)',
intro: '用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。',
inputs: [
{
key: SystemInputEnum.userChatInput,
type: FlowInputItemTypeEnum.systemInput,
type: FlowNodeInputTypeEnum.systemInput,
label: '用户问题'
}
],
@@ -87,21 +90,22 @@ export const UserInputModule: FlowModuleTemplateType = {
{
key: SystemInputEnum.userChatInput,
label: '用户问题',
type: FlowOutputItemTypeEnum.source,
valueType: FlowValueTypeEnum.string,
type: FlowNodeOutputTypeEnum.source,
valueType: FlowNodeValTypeEnum.string,
targets: []
}
]
};
export const HistoryModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.historyNode,
id: FlowNodeTypeEnum.historyNode,
flowType: FlowNodeTypeEnum.historyNode,
logo: '/imgs/module/history.png',
name: '聊天记录',
intro: '用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。',
inputs: [
{
key: 'maxContext',
type: FlowInputItemTypeEnum.numberInput,
type: FlowNodeInputTypeEnum.numberInput,
label: '最长记录数',
value: 6,
min: 0,
@@ -109,7 +113,7 @@ export const HistoryModule: FlowModuleTemplateType = {
},
{
key: SystemInputEnum.history,
type: FlowInputItemTypeEnum.hidden,
type: FlowNodeInputTypeEnum.hidden,
label: '聊天记录'
}
],
@@ -117,15 +121,15 @@ export const HistoryModule: FlowModuleTemplateType = {
{
key: SystemInputEnum.history,
label: '聊天记录',
valueType: FlowValueTypeEnum.chatHistory,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.chatHistory,
type: FlowNodeOutputTypeEnum.source,
targets: []
}
]
};
export const ChatModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.chatNode,
id: FlowNodeTypeEnum.chatNode,
flowType: FlowNodeTypeEnum.chatNode,
logo: '/imgs/module/AI.png',
name: 'AI 对话',
intro: 'AI 大模型对话',
@@ -134,7 +138,7 @@ export const ChatModule: FlowModuleTemplateType = {
Input_Template_TFSwitch,
{
key: 'model',
type: FlowInputItemTypeEnum.selectChatModel,
type: FlowNodeInputTypeEnum.selectChatModel,
label: '对话模型',
value: chatModelList?.[0]?.model,
customData: () => chatModelList,
@@ -143,7 +147,7 @@ export const ChatModule: FlowModuleTemplateType = {
},
{
key: 'temperature',
type: FlowInputItemTypeEnum.hidden,
type: FlowNodeInputTypeEnum.hidden,
label: '温度',
value: 0,
min: 0,
@@ -156,7 +160,7 @@ export const ChatModule: FlowModuleTemplateType = {
},
{
key: 'maxToken',
type: FlowInputItemTypeEnum.hidden,
type: FlowNodeInputTypeEnum.hidden,
label: '回复上限',
value: chatModelList?.[0] ? chatModelList[0].maxToken / 2 : 2000,
min: 100,
@@ -172,47 +176,47 @@ export const ChatModule: FlowModuleTemplateType = {
},
{
key: 'aiSettings',
type: FlowInputItemTypeEnum.aiSettings,
type: FlowNodeInputTypeEnum.aiSettings,
label: '',
connected: false
},
{
key: 'systemPrompt',
type: FlowInputItemTypeEnum.textarea,
type: FlowNodeInputTypeEnum.textarea,
label: '系统提示词',
max: 300,
valueType: FlowValueTypeEnum.string,
valueType: FlowNodeValTypeEnum.string,
description: ChatModelSystemTip,
placeholder: ChatModelSystemTip,
value: ''
},
{
key: SystemInputEnum.isResponseAnswerText,
type: FlowInputItemTypeEnum.hidden,
type: FlowNodeInputTypeEnum.hidden,
label: '返回AI内容',
valueType: FlowValueTypeEnum.boolean,
valueType: FlowNodeValTypeEnum.boolean,
value: true
},
{
key: 'quoteTemplate',
type: FlowInputItemTypeEnum.hidden,
type: FlowNodeInputTypeEnum.hidden,
label: '引用内容模板',
valueType: FlowValueTypeEnum.string,
valueType: FlowNodeValTypeEnum.string,
value: ''
},
{
key: 'quotePrompt',
type: FlowInputItemTypeEnum.hidden,
type: FlowNodeInputTypeEnum.hidden,
label: '引用内容提示词',
valueType: FlowValueTypeEnum.string,
valueType: FlowNodeValTypeEnum.string,
value: ''
},
{
key: 'quoteQA',
type: FlowInputItemTypeEnum.target,
type: FlowNodeInputTypeEnum.target,
label: '引用内容',
description: "对象数组格式,结构:\n [{q:'问题',a:'回答'}]",
valueType: FlowValueTypeEnum.kbQuote,
valueType: FlowNodeValTypeEnum.datasetQuote,
connected: false
},
Input_Template_History,
@@ -223,24 +227,24 @@ export const ChatModule: FlowModuleTemplateType = {
key: TaskResponseKeyEnum.history,
label: '新的上下文',
description: '将本次回复内容拼接上历史记录,作为新的上下文返回',
valueType: FlowValueTypeEnum.chatHistory,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.chatHistory,
type: FlowNodeOutputTypeEnum.source,
targets: []
},
{
key: TaskResponseKeyEnum.answerText,
label: 'AI回复',
description: '将在 stream 回复完毕后触发',
valueType: FlowValueTypeEnum.string,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.string,
type: FlowNodeOutputTypeEnum.source,
targets: []
},
Output_Template_Finish
]
};
export const KBSearchModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.datasetSearchNode,
export const DatasetSearchModule: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.datasetSearchNode,
flowType: FlowNodeTypeEnum.datasetSearchNode,
logo: '/imgs/module/db.png',
name: '知识库搜索',
intro: '去知识库中搜索对应的答案。可作为 AI 对话引用参考。',
@@ -249,7 +253,7 @@ export const KBSearchModule: FlowModuleTemplateType = {
Input_Template_TFSwitch,
{
key: 'datasets',
type: FlowInputItemTypeEnum.selectDataset,
type: FlowNodeInputTypeEnum.selectDataset,
label: '关联的知识库',
value: [],
list: [],
@@ -258,7 +262,7 @@ export const KBSearchModule: FlowModuleTemplateType = {
},
{
key: 'similarity',
type: FlowInputItemTypeEnum.slider,
type: FlowNodeInputTypeEnum.slider,
label: '相似度',
value: 0.4,
min: 0,
@@ -271,7 +275,7 @@ export const KBSearchModule: FlowModuleTemplateType = {
},
{
key: 'limit',
type: FlowInputItemTypeEnum.slider,
type: FlowNodeInputTypeEnum.slider,
label: '单次搜索上限',
description: '最多取 n 条记录作为本次问题引用',
value: 5,
@@ -289,15 +293,15 @@ export const KBSearchModule: FlowModuleTemplateType = {
{
key: 'isEmpty',
label: '搜索结果为空',
type: FlowOutputItemTypeEnum.source,
valueType: FlowValueTypeEnum.boolean,
type: FlowNodeOutputTypeEnum.source,
valueType: FlowNodeValTypeEnum.boolean,
targets: []
},
{
key: 'unEmpty',
label: '搜索结果不为空',
type: FlowOutputItemTypeEnum.source,
valueType: FlowValueTypeEnum.boolean,
type: FlowNodeOutputTypeEnum.source,
valueType: FlowNodeValTypeEnum.boolean,
targets: []
},
{
@@ -305,16 +309,16 @@ export const KBSearchModule: FlowModuleTemplateType = {
label: '引用内容',
description:
'始终返回数组,如果希望搜索结果为空时执行额外操作,需要用到上面的两个输入以及目标模块的触发器',
type: FlowOutputItemTypeEnum.source,
valueType: FlowValueTypeEnum.kbQuote,
type: FlowNodeOutputTypeEnum.source,
valueType: FlowNodeValTypeEnum.datasetQuote,
targets: []
},
Output_Template_Finish
]
};
export const AnswerModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.answerNode,
id: FlowNodeTypeEnum.answerNode,
flowType: FlowNodeTypeEnum.answerNode,
logo: '/imgs/module/reply.png',
name: '指定回复',
intro: '该模块可以直接回复一段指定的内容。常用于引导、提示',
@@ -322,9 +326,9 @@ export const AnswerModule: FlowModuleTemplateType = {
inputs: [
Input_Template_TFSwitch,
{
key: SpecialInputKeyEnum.answerText,
type: FlowInputItemTypeEnum.textarea,
valueType: FlowValueTypeEnum.any,
key: FlowNodeSpecialInputKeyEnum.answerText,
type: FlowNodeInputTypeEnum.textarea,
valueType: FlowNodeValTypeEnum.any,
value: '',
label: '回复的内容',
description:
@@ -334,7 +338,8 @@ export const AnswerModule: FlowModuleTemplateType = {
outputs: [Output_Template_Finish]
};
export const ClassifyQuestionModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.classifyQuestion,
id: FlowNodeTypeEnum.classifyQuestion,
flowType: FlowNodeTypeEnum.classifyQuestion,
logo: '/imgs/module/cq.png',
name: '问题分类',
intro: '可以判断用户问题属于哪方面问题,从而执行不同的操作。',
@@ -345,7 +350,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
Input_Template_TFSwitch,
{
key: 'model',
type: FlowInputItemTypeEnum.selectChatModel,
type: FlowNodeInputTypeEnum.selectChatModel,
label: '分类模型',
value: cqModelList?.[0]?.model,
customData: () => cqModelList,
@@ -354,8 +359,8 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
},
{
key: 'systemPrompt',
type: FlowInputItemTypeEnum.textarea,
valueType: FlowValueTypeEnum.string,
type: FlowNodeInputTypeEnum.textarea,
valueType: FlowNodeValTypeEnum.string,
value: '',
label: '背景知识',
description:
@@ -365,8 +370,8 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
Input_Template_History,
Input_Template_UserChatInput,
{
key: SpecialInputKeyEnum.agents,
type: FlowInputItemTypeEnum.custom,
key: FlowNodeSpecialInputKeyEnum.agents,
type: FlowNodeInputTypeEnum.custom,
label: '',
value: [
{
@@ -388,25 +393,26 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
{
key: 'fasw',
label: '',
type: FlowOutputItemTypeEnum.hidden,
type: FlowNodeOutputTypeEnum.hidden,
targets: []
},
{
key: 'fqsw',
label: '',
type: FlowOutputItemTypeEnum.hidden,
type: FlowNodeOutputTypeEnum.hidden,
targets: []
},
{
key: 'fesw',
label: '',
type: FlowOutputItemTypeEnum.hidden,
type: FlowNodeOutputTypeEnum.hidden,
targets: []
}
]
};
export const ContextExtractModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.contentExtract,
id: FlowNodeTypeEnum.contentExtract,
flowType: FlowNodeTypeEnum.contentExtract,
logo: '/imgs/module/extract.png',
name: '文本内容提取',
intro: '从文本中提取出指定格式的数据',
@@ -416,8 +422,8 @@ export const ContextExtractModule: FlowModuleTemplateType = {
Input_Template_TFSwitch,
{
key: ContextExtractEnum.description,
type: FlowInputItemTypeEnum.textarea,
valueType: FlowValueTypeEnum.string,
type: FlowNodeInputTypeEnum.textarea,
valueType: FlowNodeValTypeEnum.string,
value: '',
label: '提取要求描述',
description: '写一段提取要求,告诉 AI 需要提取哪些内容',
@@ -427,14 +433,14 @@ export const ContextExtractModule: FlowModuleTemplateType = {
Input_Template_History,
{
key: ContextExtractEnum.content,
type: FlowInputItemTypeEnum.target,
type: FlowNodeInputTypeEnum.target,
label: '需要提取的文本',
required: true,
valueType: FlowValueTypeEnum.string
valueType: FlowNodeValTypeEnum.string
},
{
key: ContextExtractEnum.extractKeys,
type: FlowInputItemTypeEnum.custom,
type: FlowNodeInputTypeEnum.custom,
label: '目标字段',
description: "由 '描述' 和 'key' 组成一个目标字段,可提取多个目标字段",
value: []
@@ -444,29 +450,30 @@ export const ContextExtractModule: FlowModuleTemplateType = {
{
key: ContextExtractEnum.success,
label: '字段完全提取',
valueType: FlowValueTypeEnum.boolean,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.boolean,
type: FlowNodeOutputTypeEnum.source,
targets: []
},
{
key: ContextExtractEnum.failed,
label: '提取字段缺失',
valueType: FlowValueTypeEnum.boolean,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.boolean,
type: FlowNodeOutputTypeEnum.source,
targets: []
},
{
key: ContextExtractEnum.fields,
label: '完整提取结果',
description: '一个 JSON 字符串,例如:{"name:":"YY","Time":"2023/7/2 18:00"}',
valueType: FlowValueTypeEnum.string,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.string,
type: FlowNodeOutputTypeEnum.source,
targets: []
}
]
};
export const HttpModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.httpRequest,
id: FlowNodeTypeEnum.httpRequest,
flowType: FlowNodeTypeEnum.httpRequest,
logo: '/imgs/module/http.png',
name: 'HTTP模块',
intro: '可以发出一个 HTTP POST 请求,实现更为复杂的操作(联网搜索、数据库查询等)',
@@ -477,7 +484,7 @@ export const HttpModule: FlowModuleTemplateType = {
{
key: HttpPropsEnum.url,
value: '',
type: FlowInputItemTypeEnum.input,
type: FlowNodeInputTypeEnum.input,
label: '请求地址',
description: '请求目标地址',
placeholder: 'https://api.fastgpt.run/getInventory',
@@ -488,7 +495,8 @@ export const HttpModule: FlowModuleTemplateType = {
outputs: [Output_Template_Finish]
};
export const EmptyModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.empty,
id: FlowNodeTypeEnum.empty,
flowType: FlowNodeTypeEnum.empty,
logo: '/imgs/module/cq.png',
name: '该模块已被移除',
intro: '',
@@ -496,10 +504,11 @@ export const EmptyModule: FlowModuleTemplateType = {
inputs: [],
outputs: []
};
export const AppModule: FlowModuleTemplateType = {
flowType: FlowModuleTypeEnum.app,
export const RunAppModule: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.runApp,
flowType: FlowNodeTypeEnum.runApp,
logo: '/imgs/module/app.png',
name: '应用调用(测试版)',
name: '应用调用',
intro: '可以选择一个其他应用进行调用',
description: '可以选择一个其他应用进行调用',
showStatus: true,
@@ -507,7 +516,7 @@ export const AppModule: FlowModuleTemplateType = {
Input_Template_TFSwitch,
{
key: 'app',
type: FlowInputItemTypeEnum.selectApp,
type: FlowNodeInputTypeEnum.selectApp,
label: '选择一个应用',
description: '选择一个其他应用进行调用',
required: true
@@ -520,38 +529,87 @@ export const AppModule: FlowModuleTemplateType = {
key: TaskResponseKeyEnum.history,
label: '新的上下文',
description: '将该应用回复内容拼接到历史记录中,作为新的上下文返回',
valueType: FlowValueTypeEnum.chatHistory,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.chatHistory,
type: FlowNodeOutputTypeEnum.source,
targets: []
},
{
key: TaskResponseKeyEnum.answerText,
label: 'AI回复',
description: '将在应用完全结束后触发',
valueType: FlowValueTypeEnum.string,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.string,
type: FlowNodeOutputTypeEnum.source,
targets: []
},
Output_Template_Finish
]
};
export const PluginInputModule: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.pluginInput,
flowType: FlowNodeTypeEnum.pluginInput,
logo: '/imgs/module/input.png',
name: '定义插件输入',
intro: '自定义配置外部输入,使用插件时,仅暴露自定义配置的输入',
description: '自定义配置外部输入,使用插件时,仅暴露自定义配置的输入',
showStatus: false,
inputs: [],
outputs: []
};
export const PluginOutputModule: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.pluginOutput,
flowType: FlowNodeTypeEnum.pluginOutput,
logo: '/imgs/module/output.png',
name: '定义插件输出',
intro: '自定义配置外部输出,使用插件时,仅暴露自定义配置的输出',
description: '自定义配置外部输出,使用插件时,仅暴露自定义配置的输出',
showStatus: false,
inputs: [],
outputs: []
};
export const PluginModule: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.pluginModule,
flowType: FlowNodeTypeEnum.pluginModule,
logo: '/imgs/module/custom.png',
name: '自定义模块',
showStatus: false,
inputs: [],
outputs: []
};
export const ModuleTemplates = [
{
label: '输入模块',
list: [UserInputModule, HistoryModule]
},
export const SystemModuleTemplates = [
{
label: '引导模块',
list: [UserGuideModule]
},
{
label: '输入模块',
list: [UserInputModule, HistoryModule]
},
{
label: '内容生成',
list: [ChatModule, AnswerModule]
},
{
label: '核心调用',
list: [KBSearchModule, AppModule]
list: [DatasetSearchModule, RunAppModule]
},
{
label: '函数模块',
list: [ClassifyQuestionModule, ContextExtractModule, HttpModule]
}
];
export const PluginModuleTemplates = [
{
label: '输入输出',
list: [PluginInputModule, PluginOutputModule, HistoryModule]
},
{
label: '内容生成',
list: [ChatModule, AnswerModule]
},
{
label: '核心调用',
list: [DatasetSearchModule, RunAppModule]
},
{
label: '函数模块',
@@ -564,13 +622,16 @@ export const ModuleTemplatesFlat = [
UserInputModule,
HistoryModule,
ChatModule,
KBSearchModule,
DatasetSearchModule,
AnswerModule,
ClassifyQuestionModule,
ContextExtractModule,
HttpModule,
EmptyModule,
AppModule
RunAppModule,
PluginInputModule,
PluginOutputModule,
PluginModule
];
// template
@@ -665,7 +726,7 @@ export const appTemplates: (AppItemType & {
{
key: 'history',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
type: 'source',
targets: [
{
@@ -757,14 +818,14 @@ export const appTemplates: (AppItemType & {
key: 'quoteQA',
type: 'target',
label: '引用内容',
valueType: 'kb_quote',
valueType: 'datasetQuote',
connected: false
},
{
key: 'history',
type: 'target',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
connected: true
},
{
@@ -886,7 +947,7 @@ export const appTemplates: (AppItemType & {
{
key: 'history',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
type: 'source',
targets: [
{
@@ -1003,7 +1064,7 @@ export const appTemplates: (AppItemType & {
description:
'始终返回数组,如果希望搜索结果为空时执行额外操作,需要用到上面的两个输入以及目标模块的触发器',
type: 'source',
valueType: 'kb_quote',
valueType: 'datasetQuote',
targets: [
{
moduleId: 'chatModule',
@@ -1094,14 +1155,14 @@ export const appTemplates: (AppItemType & {
key: 'quoteQA',
type: 'target',
label: '引用内容',
valueType: 'kb_quote',
valueType: 'datasetQuote',
connected: true
},
{
key: 'history',
type: 'target',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
connected: true
},
{
@@ -1292,7 +1353,7 @@ export const appTemplates: (AppItemType & {
{
key: 'history',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
type: 'source',
targets: [
{
@@ -1401,14 +1462,14 @@ export const appTemplates: (AppItemType & {
type: 'custom',
label: '引用内容',
description: "对象数组格式,结构:\n [{q:'问题',a:'回答'}]",
valueType: 'kb_quote',
valueType: 'datasetQuote',
connected: false
},
{
key: 'history',
type: 'target',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
connected: true
},
{
@@ -1441,7 +1502,7 @@ export const appTemplates: (AppItemType & {
key: 'history',
label: '新的上下文',
description: '将本次回复内容拼接上历史记录,作为新的上下文返回',
valueType: 'chat_history',
valueType: 'chatHistory',
type: 'source',
targets: []
}
@@ -1520,7 +1581,7 @@ export const appTemplates: (AppItemType & {
{
key: 'history',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
type: 'source',
targets: [
{
@@ -1564,7 +1625,7 @@ export const appTemplates: (AppItemType & {
key: 'history',
type: 'target',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
connected: true
},
{
@@ -1863,14 +1924,14 @@ export const appTemplates: (AppItemType & {
type: 'custom',
label: '引用内容',
description: "对象数组格式,结构:\n [{q:'问题',a:'回答'}]",
valueType: 'kb_quote',
valueType: 'datasetQuote',
connected: true
},
{
key: 'history',
type: 'target',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
connected: true
},
{
@@ -1903,7 +1964,7 @@ export const appTemplates: (AppItemType & {
key: 'history',
label: '新的上下文',
description: '将本次回复内容拼接上历史记录,作为新的上下文返回',
valueType: 'chat_history',
valueType: 'chatHistory',
type: 'source',
targets: []
}
@@ -1938,7 +1999,7 @@ export const appTemplates: (AppItemType & {
{
key: 'history',
label: '聊天记录',
valueType: 'chat_history',
valueType: 'chatHistory',
type: 'source',
targets: [
{
@@ -2055,7 +2116,7 @@ export const appTemplates: (AppItemType & {
description:
'始终返回数组,如果希望搜索结果为空时执行额外操作,需要用到上面的两个输入以及目标模块的触发器',
type: 'source',
valueType: 'kb_quote',
valueType: 'datasetQuote',
targets: [
{
moduleId: 'nlfwkc',

View File

@@ -1,86 +1,68 @@
import type { BoxProps } from '@chakra-ui/react';
import { FlowNodeTypeEnum, FlowNodeValTypeEnum } from '@fastgpt/global/core/module/node/constant';
export enum FlowInputItemTypeEnum {
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',
chatInput = 'chatInput',
selectApp = 'selectApp',
// chat special input
aiSettings = 'aiSettings',
maxToken = 'maxToken',
selectChatModel = 'selectChatModel',
// dataset special input
selectDataset = 'selectDataset',
hidden = 'hidden'
}
export enum FlowOutputItemTypeEnum {
answer = 'answer',
source = 'source',
hidden = 'hidden'
}
export enum FlowModuleTypeEnum {
empty = 'empty',
variable = 'variable',
userGuide = 'userGuide',
questionInput = 'questionInput',
historyNode = 'historyNode',
chatNode = 'chatNode',
datasetSearchNode = 'datasetSearchNode',
tfSwitchNode = 'tfSwitchNode',
answerNode = 'answerNode',
classifyQuestion = 'classifyQuestion',
contentExtract = 'contentExtract',
httpRequest = 'httpRequest',
app = 'app'
}
export enum SpecialInputKeyEnum {
'answerText' = 'text',
'agents' = 'agents' // cq agent key
}
export enum FlowValueTypeEnum {
'string' = 'string',
'number' = 'number',
'boolean' = 'boolean',
'chatHistory' = 'chat_history',
'kbQuote' = 'kb_quote',
'any' = 'any'
}
export const FlowValueTypeStyle: Record<`${FlowValueTypeEnum}`, BoxProps> = {
[FlowValueTypeEnum.string]: {
export const FlowValueTypeStyle: Record<`${FlowNodeValTypeEnum}`, BoxProps> = {
[FlowNodeValTypeEnum.string]: {
background: '#36ADEF'
},
[FlowValueTypeEnum.number]: {
[FlowNodeValTypeEnum.number]: {
background: '#FB7C3C'
},
[FlowValueTypeEnum.boolean]: {
[FlowNodeValTypeEnum.boolean]: {
background: '#E7D118'
},
[FlowValueTypeEnum.chatHistory]: {
[FlowNodeValTypeEnum.chatHistory]: {
background: '#00A9A6'
},
[FlowValueTypeEnum.kbQuote]: {
[FlowNodeValTypeEnum.datasetQuote]: {
background: '#A558C9'
},
[FlowValueTypeEnum.any]: {
[FlowNodeValTypeEnum.any]: {
background: '#9CA2A8'
}
};
export const FlowValueTypeTip = {
[FlowNodeValTypeEnum.string]: {
label: 'app.module.valueType.string',
example: ''
},
[FlowNodeValTypeEnum.number]: {
label: 'app.module.valueType.number',
example: ''
},
[FlowNodeValTypeEnum.boolean]: {
label: 'app.module.valueType.boolean',
example: ''
},
[FlowNodeValTypeEnum.chatHistory]: {
label: 'app.module.valueType.chatHistory',
example: `{
obj: System | Human | AI;
value: string;
}`
},
[FlowNodeValTypeEnum.datasetQuote]: {
label: 'app.module.valueType.datasetQuote',
example: `{
id: string;
datasetId: string;
collectionId: string;
sourceName: string;
sourceId?: string;
q: string;
a: string
}`
},
[FlowNodeValTypeEnum.any]: {
label: 'app.module.valueType.any',
example: ''
}
};
export const initModuleType: Record<string, boolean> = {
[FlowModuleTypeEnum.historyNode]: true,
[FlowModuleTypeEnum.questionInput]: true
[FlowNodeTypeEnum.historyNode]: true,
[FlowNodeTypeEnum.questionInput]: true,
[FlowNodeTypeEnum.pluginInput]: true
};
export const edgeOptions = {

View File

@@ -1,25 +1,28 @@
import type { FlowInputItemType } from '@/types/core/app/flow';
import type { FlowNodeInputItemType } from '@fastgpt/global/core/module/node/type.d';
import { SystemInputEnum } from '../app';
import { FlowInputItemTypeEnum, FlowValueTypeEnum } from './index';
import {
FlowNodeInputTypeEnum,
FlowNodeValTypeEnum
} from '@fastgpt/global/core/module/node/constant';
export const Input_Template_TFSwitch: FlowInputItemType = {
export const Input_Template_TFSwitch: FlowNodeInputItemType = {
key: SystemInputEnum.switch,
type: FlowInputItemTypeEnum.target,
type: FlowNodeInputTypeEnum.target,
label: '触发器',
valueType: FlowValueTypeEnum.any
valueType: FlowNodeValTypeEnum.any
};
export const Input_Template_History: FlowInputItemType = {
export const Input_Template_History: FlowNodeInputItemType = {
key: SystemInputEnum.history,
type: FlowInputItemTypeEnum.target,
type: FlowNodeInputTypeEnum.target,
label: '聊天记录',
valueType: FlowValueTypeEnum.chatHistory
valueType: FlowNodeValTypeEnum.chatHistory
};
export const Input_Template_UserChatInput: FlowInputItemType = {
export const Input_Template_UserChatInput: FlowNodeInputItemType = {
key: SystemInputEnum.userChatInput,
type: FlowInputItemTypeEnum.target,
type: FlowNodeInputTypeEnum.target,
label: '用户问题',
required: true,
valueType: FlowValueTypeEnum.string
valueType: FlowNodeValTypeEnum.string
};

View File

@@ -1,12 +1,15 @@
import type { FlowOutputItemType } from '@/types/core/app/flow';
import type { FlowNodeOutputItemType } from '@fastgpt/global/core/module/node/type';
import { SystemOutputEnum } from '../app';
import { FlowOutputItemTypeEnum, FlowValueTypeEnum } from './index';
import {
FlowNodeOutputTypeEnum,
FlowNodeValTypeEnum
} from '@fastgpt/global/core/module/node/constant';
export const Output_Template_Finish: FlowOutputItemType = {
export const Output_Template_Finish: FlowNodeOutputItemType = {
key: SystemOutputEnum.finish,
label: '模块调用结束',
description: '模块调用结束时触发',
valueType: FlowValueTypeEnum.boolean,
type: FlowOutputItemTypeEnum.source,
valueType: FlowNodeValTypeEnum.boolean,
type: FlowNodeOutputTypeEnum.source,
targets: []
};

View File

@@ -25,18 +25,3 @@ export enum PromotionEnum {
register = 'register',
pay = 'pay'
}
export enum InformTypeEnum {
system = 'system'
}
export const InformTypeMap = {
[InformTypeEnum.system]: {
label: '系统通知'
}
};
export enum MyModelsTypeEnum {
my = 'my',
collection = 'collection'
}