Perf workflow (#1492)

* perf: handle edge check

* search model

* feat: plugin input can render all input; fix: plugin default value

* fix ts

* feat: plugin input support required
This commit is contained in:
Archer
2024-05-15 16:17:43 +08:00
committed by GitHub
parent cd876251b7
commit 8386f707cd
36 changed files with 256 additions and 160 deletions

View File

@@ -8,6 +8,7 @@ type I18nContextType = {
datasetT: TFunction<['dataset'], undefined>;
fileT: TFunction<['file'], undefined>;
publishT: TFunction<['publish'], undefined>;
workflowT: TFunction<['workflow'], undefined>;
};
export const I18nContext = createContext<I18nContextType>({
@@ -21,6 +22,7 @@ const I18nContextProvider = ({ children }: { children: React.ReactNode }) => {
const { t: datasetT } = useTranslation('dataset');
const { t: fileT } = useTranslation('file');
const { t: publishT } = useTranslation('publish');
const { t: workflowT } = useTranslation('workflow');
return (
<I18nContext.Provider
@@ -29,7 +31,8 @@ const I18nContextProvider = ({ children }: { children: React.ReactNode }) => {
appT,
datasetT,
fileT,
publishT
publishT,
workflowT
}}
>
{children}

View File

@@ -1,7 +1,10 @@
import { AppItemType } from '@/types/app';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
import { FlowNodeInputTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
import {
FlowNodeInputTypeEnum,
FlowNodeTypeEnum
} from '@fastgpt/global/core/workflow/node/constant';
// template
export const appTemplates: (AppItemType & {
@@ -21,7 +24,7 @@ export const appTemplates: (AppItemType & {
name: '系统配置',
intro: '可以配置应用的系统参数',
avatar: '/imgs/workflow/userGuide.png',
flowNodeType: 'userGuide',
flowNodeType: FlowNodeTypeEnum.systemConfig,
position: {
x: 531.2422736065552,
y: -486.7611729549753
@@ -84,7 +87,7 @@ export const appTemplates: (AppItemType & {
name: '流程开始',
intro: '',
avatar: '/imgs/workflow/userChatInput.svg',
flowNodeType: 'workflowStart',
flowNodeType: FlowNodeTypeEnum.workflowStart,
position: {
x: 558.4082376415505,
y: 123.72387429194112
@@ -115,7 +118,7 @@ export const appTemplates: (AppItemType & {
name: 'AI 对话',
intro: 'AI 大模型对话',
avatar: '/imgs/workflow/AI.png',
flowNodeType: 'chatNode',
flowNodeType: FlowNodeTypeEnum.chatNode,
showStatus: true,
position: {
x: 1097.7317280958762,
@@ -251,7 +254,7 @@ export const appTemplates: (AppItemType & {
name: '系统配置',
intro: '可以配置应用的系统参数',
avatar: '/imgs/workflow/userGuide.png',
flowNodeType: 'userGuide',
flowNodeType: FlowNodeTypeEnum.systemConfig,
position: {
x: 496.57560693988853,
y: -490.7611729549753
@@ -331,7 +334,7 @@ export const appTemplates: (AppItemType & {
name: '流程开始',
intro: '',
avatar: '/imgs/workflow/userChatInput.svg',
flowNodeType: 'workflowStart',
flowNodeType: FlowNodeTypeEnum.workflowStart,
position: {
x: 558.4082376415505,
y: 123.72387429194112
@@ -362,7 +365,7 @@ export const appTemplates: (AppItemType & {
name: 'AI 对话',
intro: 'AI 大模型对话',
avatar: '/imgs/workflow/AI.png',
flowNodeType: 'chatNode',
flowNodeType: FlowNodeTypeEnum.chatNode,
showStatus: true,
position: {
x: 1097.7317280958762,
@@ -498,7 +501,7 @@ export const appTemplates: (AppItemType & {
name: '系统配置',
intro: '可以配置应用的系统参数',
avatar: '/imgs/workflow/userGuide.png',
flowNodeType: 'userGuide',
flowNodeType: FlowNodeTypeEnum.systemConfig,
position: {
x: 531.2422736065552,
y: -486.7611729549753
@@ -561,7 +564,7 @@ export const appTemplates: (AppItemType & {
name: '流程开始',
intro: '',
avatar: '/imgs/workflow/userChatInput.svg',
flowNodeType: 'workflowStart',
flowNodeType: FlowNodeTypeEnum.workflowStart,
position: {
x: 558.4082376415505,
y: 123.72387429194112
@@ -592,7 +595,7 @@ export const appTemplates: (AppItemType & {
name: 'AI 对话',
intro: 'AI 大模型对话',
avatar: '/imgs/workflow/AI.png',
flowNodeType: 'chatNode',
flowNodeType: FlowNodeTypeEnum.chatNode,
showStatus: true,
position: {
x: 1638.509551404687,
@@ -712,7 +715,7 @@ export const appTemplates: (AppItemType & {
name: '知识库搜索',
intro: '调用“语义检索”和“全文检索”能力,从“知识库”中查找可能与问题相关的参考内容',
avatar: '/imgs/workflow/db.png',
flowNodeType: 'datasetSearchNode',
flowNodeType: FlowNodeTypeEnum.datasetSearchNode,
showStatus: true,
position: {
x: 918.5901682164496,
@@ -826,7 +829,7 @@ export const appTemplates: (AppItemType & {
name: '系统配置',
intro: '可以配置应用的系统参数',
avatar: '/imgs/workflow/userGuide.png',
flowNodeType: 'userGuide',
flowNodeType: FlowNodeTypeEnum.systemConfig,
position: {
x: 531.2422736065552,
y: -486.7611729549753
@@ -889,7 +892,7 @@ export const appTemplates: (AppItemType & {
name: '流程开始',
intro: '',
avatar: '/imgs/workflow/userChatInput.svg',
flowNodeType: 'workflowStart',
flowNodeType: FlowNodeTypeEnum.workflowStart,
position: {
x: 558.4082376415505,
y: 123.72387429194112
@@ -920,7 +923,7 @@ export const appTemplates: (AppItemType & {
name: 'AI 对话',
intro: 'AI 大模型对话',
avatar: '/imgs/workflow/AI.png',
flowNodeType: 'chatNode',
flowNodeType: FlowNodeTypeEnum.chatNode,
showStatus: true,
position: {
x: 2701.1267277679685,
@@ -1041,7 +1044,7 @@ export const appTemplates: (AppItemType & {
intro:
'根据用户的历史记录和当前问题判断该次提问的类型。可以添加多组问题类型,下面是一个模板例子:\n类型1: 打招呼\n类型2: 关于商品“使用”问题\n类型3: 关于商品“购买”问题\n类型4: 其他问题',
avatar: '/imgs/workflow/cq.png',
flowNodeType: 'classifyQuestion',
flowNodeType: FlowNodeTypeEnum.classifyQuestion,
showStatus: true,
position: {
x: 1020.9667229609946,
@@ -1123,7 +1126,7 @@ export const appTemplates: (AppItemType & {
intro:
'该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。',
avatar: '/imgs/workflow/reply.png',
flowNodeType: 'answerNode',
flowNodeType: FlowNodeTypeEnum.answerNode,
position: {
x: 1874.9167551056487,
y: 434.98431875888207
@@ -1148,7 +1151,7 @@ export const appTemplates: (AppItemType & {
name: '知识库搜索',
intro: '调用“语义检索”和“全文检索”能力,从“知识库”中查找可能与问题相关的参考内容',
avatar: '/imgs/workflow/db.png',
flowNodeType: 'datasetSearchNode',
flowNodeType: FlowNodeTypeEnum.datasetSearchNode,
showStatus: true,
position: {
x: 1851.010152279949,

View File

@@ -75,7 +75,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType {
name: '流程开始',
intro: '',
avatar: '/imgs/workflow/userChatInput.svg',
flowNodeType: 'workflowStart',
flowNodeType: FlowNodeTypeEnum.workflowStart,
position: {
x: 558.4082376415505,
y: 123.72387429194112
@@ -111,7 +111,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType {
name: 'AI 对话',
intro: 'AI 大模型对话',
avatar: '/imgs/workflow/AI.png',
flowNodeType: 'chatNode',
flowNodeType: FlowNodeTypeEnum.chatNode,
showStatus: true,
position: {
x: 1106.3238387960757,
@@ -244,7 +244,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType {
name: 'AI 对话',
intro: 'AI 大模型对话',
avatar: '/imgs/workflow/AI.png',
flowNodeType: 'chatNode',
flowNodeType: FlowNodeTypeEnum.chatNode,
showStatus: true,
position: {
x: 1638.509551404687,
@@ -364,7 +364,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType {
name: '知识库搜索',
intro: '调用“语义检索”和“全文检索”能力,从“知识库”中查找可能与问题相关的参考内容',
avatar: '/imgs/workflow/db.png',
flowNodeType: 'datasetSearchNode',
flowNodeType: FlowNodeTypeEnum.datasetSearchNode,
showStatus: true,
position: {
x: 918.5901682164496,
@@ -483,7 +483,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType {
name: '知识库搜索',
intro: '调用“语义检索”和“全文检索”能力,从“知识库”中查找可能与问题相关的参考内容',
avatar: '/imgs/workflow/db.png',
flowNodeType: 'datasetSearchNode',
flowNodeType: FlowNodeTypeEnum.datasetSearchNode,
showStatus: true,
position: {
x: 500,
@@ -626,7 +626,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType {
name: '工具调用(实验)',
intro: '通过AI模型自动选择一个或多个功能块进行调用也可以对插件进行调用。',
avatar: '/imgs/workflow/tool.svg',
flowNodeType: 'tools',
flowNodeType: FlowNodeTypeEnum.tools,
showStatus: true,
position: {
x: 1062.1738942532802,

View File

@@ -70,7 +70,9 @@ export const FlowValueTypeMap = {
[WorkflowIOValueTypeEnum.selectDataset]: {
label: '选择知识库',
value: WorkflowIOValueTypeEnum.selectDataset,
description: ''
description: `{
datasetId: string;
}`
},
[WorkflowIOValueTypeEnum.any]: {
label: 'any',

View File

@@ -323,7 +323,12 @@ export const updateFlowNodeVersion = (
});
}
const updatedNode: FlowNodeItemType = { ...node, ...template, name: node.name };
const updatedNode: FlowNodeItemType = {
...node,
...template,
name: node.name,
intro: node.intro
};
if (node.inputs && template.inputs) {
updatedNode.inputs = updateArrayBasedOnTemplate(node.inputs, template.inputs);