yangyin
2024-12-13 c6cf46f3e11e60f692e0b8d12188458ad1b6120e
src/components/vue-flow/VueFlowHelper.ts
@@ -19,6 +19,10 @@
      };
      switch (type) {
         case NodeType.Start:
            data = {
               ...data,
               description: '工作流运行的起始节点。',
            };
            data[VueFlowConstant.GROUP_PARAMS_KEY] = [
               {
                  [VueFlowConstant.PARAMS_KEY]: [
@@ -32,7 +36,17 @@
               },
            ];
            break;
         case NodeType.End:
            data = {
               ...data,
               description: '工作流运行到此结束。',
            };
            break;
         case NodeType.Condition:
            data = {
               ...data,
               description: '根据条件表达式执行不同的分支。',
            };
            data[VueFlowConstant.GROUP_PARAMS_KEY] = [
               {
                  [VueFlowConstant.PARAMS_KEY]: [
@@ -40,13 +54,17 @@
                        key: 'condition',
                        label: '',
                        type: 'condition',
                        value: [ConditionHelper.getDefaultConditionGroup(),ConditionHelper.getDefaultConditionGroup(true)],
                        value: [ConditionHelper.getDefaultConditionGroup(), ConditionHelper.getDefaultConditionGroup(true)],
                     },
                  ],
               },
            ];
            break;
         case NodeType.LLM:
            data = {
               ...data,
               description: '调用大模型回答用户问题或者处理任务。',
            };
            data[VueFlowConstant.GROUP_PARAMS_KEY] = [
               {
                  name: '模型设置',
@@ -65,7 +83,7 @@
               },
               {
                  name: '提示词',
                  [VueFlowConstant.PARAMS_KEY]: [{ key: 'prompt', label: '提示词', type: 'textarea', value: '' }],
                  [VueFlowConstant.PARAMS_KEY]: [{ key: 'prompt', label: '', type: 'textarea', value: '' }],
               },
            ];
            break;
@@ -73,21 +91,46 @@
         case NodeType.Agent:
            data[VueFlowConstant.GROUP_PARAMS_KEY] = [
               {
                  name: '代理名称',
                  [VueFlowConstant.PARAMS_KEY]: [
                     {
                        key: 'agent',
                        label: '代理',
                        label: '',
                        type: 'agent_select',
                        value: '',
                        // value_label:'',
                        required: true,
                        placeholder: '代理',
                        placeholder: '代理名称',
                     },
                  ],
               },
            ];
            break;
         case NodeType.Func:
            data[VueFlowConstant.GROUP_PARAMS_KEY] = [
               {
                  name: '函数名称',
                  [VueFlowConstant.PARAMS_KEY]: [
                     {
                        key: 'func_name',
                        label: '',
                        type: 'func_name_select',
                        value: '',
                        // value_label:'',
                        required: true,
                        placeholder: '函数名称',
                     },
                  ],
               },
            ];
            break;
         case NodeType.Output:
            data = {
               ...data,
               description:
                  '可向用户发送消息,并且支持进行更丰富的交互,例如请求用户批准进行某项敏感操作、允许用户在模型输出内容的基础上直接修改并提交。',
            };
            data[VueFlowConstant.GROUP_PARAMS_KEY] = [
               {
                  [VueFlowConstant.PARAMS_KEY]: [
@@ -117,6 +160,22 @@
            break;
      }
      return data;
   };
   /**
    * 强制写入到配置信息中,用于 patch 过去版本中没有的字段,或字段名称已经修改
    *
    * 版本稳定后可删除此方法
    * @param obj
    * @param key
    * @param val
    */
   static getConfigValue = (obj: any, key: string, val: string) => {
      const value = obj[key];
      if (!value || value !== val) {
         obj[key] = val;
      }
      return val;
   };
   static getHandleId = (node: any, handleType: HandleType, order?: number) => {
@@ -212,9 +271,7 @@
         : {
               id: VueFlowHelper.genId(),
               operator: ConditionOperator.And,
               conditions: [
                  ConditionHelper.getConditionItem()
               ],
               conditions: [ConditionHelper.getConditionItem()],
           };
   };
}