From d1a8061067e21463d8544be8bd840984596ed4a9 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期四, 02 一月 2025 16:08:42 +0800
Subject: [PATCH] 工作流查看

---
 src/components/vue-flow/VueFlowHelper.ts |  128 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 122 insertions(+), 6 deletions(-)

diff --git a/src/components/vue-flow/VueFlowHelper.ts b/src/components/vue-flow/VueFlowHelper.ts
index bda2965..9b05a81 100644
--- a/src/components/vue-flow/VueFlowHelper.ts
+++ b/src/components/vue-flow/VueFlowHelper.ts
@@ -1,8 +1,8 @@
-import { HandleType, useNode, useVueFlow } from '@vue-flow/core';
+import type { HandleType } from '@vue-flow/core';
 import { v4 as uuid } from 'uuid';
 import { VueFlowConstant } from './VueFlowConstant';
-import { CompareOperation, ConditionOperator, NodeType, VarType, nodeTypeMap } from './vueFlowEnum';
-import { get } from 'lodash';
+import type { CompareOperation } from './vueFlowEnum';
+import { ConditionOperator, NodeType, VarType, nodeTypeMap } from './vueFlowEnum';
 
 export class VueFlowHelper {
 	static genId() {
@@ -66,6 +66,7 @@
 					description: '璋冪敤澶фā鍨嬪洖绛旂敤鎴烽棶棰樻垨鑰呭鐞嗕换鍔°��',
 				};
 				data[VueFlowConstant.GROUP_PARAMS_KEY] = [
+					
 					{
 						name: '妯″瀷璁剧疆',
 
@@ -85,9 +86,121 @@
 						name: '鎻愮ず璇�',
 						[VueFlowConstant.PARAMS_KEY]: [{ key: 'prompt', label: '', type: 'textarea', value: '' }],
 					},
+					{
+						name: '杈撳嚭鍙傛暟鍚�',
+						[VueFlowConstant.PARAMS_KEY]: [{ key: 'key',  type: 'input', value: '' }],
+					},
 				];
 				break;
-
+				case NodeType.Analysis:
+					data = {
+						...data,
+						description: '',
+					};
+					data[VueFlowConstant.GROUP_PARAMS_KEY] = [
+						{
+							name: '鍒嗘瀽璁剧疆',
+	
+							[VueFlowConstant.PARAMS_KEY]: [
+								{
+									key: 'llm_model',
+									label: '妯″瀷',
+									type: 'llm_model',
+									value: '',
+									required: true,
+									placeholder: '璇烽�夋嫨妯″瀷',
+								},
+								{ key: 'temperature', label: '娓╁害', type: 'slide', scope: [0, 2], step: 0.1, value: 0.6 },
+							],
+						},
+						{
+							name: '鎻愮ず璇�',
+							[VueFlowConstant.PARAMS_KEY]: [{ key: 'prompt', label: '', type: 'textarea', value: '' }],
+						},
+					];
+					break;
+			case NodeType.Code:
+				data = {
+					...data,
+					description: '鑷畾涔夐渶瑕佹墽琛岀殑浠g爜銆�',
+					[VueFlowConstant.GROUP_PARAMS_KEY]: [
+						{
+							name: '鍏ュ弬',
+							[VueFlowConstant.PARAMS_KEY]: [
+								{
+									key: 'code_input',
+									type: 'code_input',
+									required: true,
+									value: [
+										{ key: 'arg1', type: 'input', label: '', value: '' },
+										{ key: 'arg2', type: 'input', label: '', value: '' },
+									],
+								},
+							],
+						},
+						{
+							name: '鎵ц浠g爜',
+							[VueFlowConstant.PARAMS_KEY]: [
+								{
+									key: 'code',
+									type: 'code',
+									required: true,
+									value: 'const main = (arg1, arg2) =>{\n  return {\n    result1: arg1,\n    result2: arg2\n  }\n}',
+									language: ['text', 'javascript'],
+									defaultLanguage: 'javascript',
+								},
+							],
+						},
+						{
+							name: '鍑哄弬',
+							[VueFlowConstant.PARAMS_KEY]: [
+								{
+									key: 'code_output',
+									type: 'code_output',
+									// global: 'code:value.map(el => ({ label: el.key, value: el.key }))',
+									required: true,
+									value: [
+										{ key: 'result1', type: 'string' },
+										{ key: 'result2', type: 'string' },
+									],
+								},
+							],
+						},
+					],
+				};
+				break;
+			case NodeType.TextResource:
+				data = {
+					...data,
+					// description: '鑷畾涔夐渶瑕佹墽琛岀殑浠g爜銆�',
+					[VueFlowConstant.GROUP_PARAMS_KEY]: [
+						{
+							name: '鍙傛暟鍚�',
+							[VueFlowConstant.PARAMS_KEY]: [
+								{
+									key: 'key',
+									type: 'input',
+									required: true,
+									value: '',
+								},
+							],
+						},
+						{
+							name: '鍙傛暟鍊�',
+							[VueFlowConstant.PARAMS_KEY]: [
+								{
+									key: 'resource_value',
+									type: 'resource_value',
+									required: true,
+									value: '',
+									language: ['text', 'javascript'],
+									defaultLanguage: 'text',
+								},
+							],
+						},
+					],
+				};
+				break;
 			case NodeType.Agent:
 				data[VueFlowConstant.GROUP_PARAMS_KEY] = [
 					{
@@ -170,13 +283,16 @@
 	 * @param key
 	 * @param val
 	 */
-	static getConfigValue = (obj: any, key: string, val: string) => {
+	static getConfigValue = (obj: any, key: string, val: any) => {
 		const value = obj[key];
 		if (!value || value !== val) {
 			obj[key] = val;
 		}
+
 		return val;
 	};
+
+
 
 	static getHandleId = (node: any, handleType: HandleType, order?: number) => {
 		const orderSuffix = order == undefined ? '' : `__${order + ''}`;
@@ -184,7 +300,7 @@
 	};
 
 	static getFieldValue = (data, key, index = 0) => {
-		let varList = [];
+		const varList = [];
 		const group = data?.[VueFlowConstant.GROUP_PARAMS_KEY];
 		if (group && group.length > 0) {
 			if (index !== null) {

--
Gitblit v1.9.3