@@ -10,7 +10,7 @@ import {
1010 DATA_TYPES ,
1111 DEFAULT_KNOWLEDGE_REPO_GROUP_STRUCT ,
1212 DEFAULT_LLM_KNOWLEDGE_BASES ,
13- DEFAULT_LLM_REFERENCE_OUTPUT ,
13+ DEFAULT_LLM_REFERENCE_OUTPUT , DEFAULT_LOOP_NODE_CONTEXT ,
1414 DEFAULT_MAX_MEMORY_ROUNDS ,
1515 END_NODE_TYPE ,
1616 FLOW_TYPE ,
@@ -49,6 +49,8 @@ export const pageCompatibilityProcessor = (pageData, graph) => {
4949 return knowledgeRetrievalCompatibilityProcessor ( shapeData , g , self ) ;
5050 case 'questionClassificationNodeCondition' :
5151 return questionClassificationCompatibilityProcessor ( shapeData , g , self ) ;
52+ case 'loopNodeState' :
53+ return loopNodeCompatibilityProcessor ( shapeData , g , self ) ;
5254 default :
5355 return shapeCompatibilityProcessor ( shapeData , g , self ) ;
5456 }
@@ -185,6 +187,30 @@ export const questionClassificationCompatibilityProcessor = (shapeData, graph, p
185187 return self ;
186188} ;
187189
190+ /**
191+ * 循环节点兼容性处理器.
192+ *
193+ * @override
194+ */
195+ export const loopNodeCompatibilityProcessor = ( shapeData , graph , pageHandler ) => {
196+ const self = shapeCompatibilityProcessor ( shapeData , graph , pageHandler ) ;
197+
198+ /**
199+ * @override
200+ */
201+ const process = self . process ;
202+ self . process = ( ) => {
203+ process . apply ( self ) ;
204+ const jober = self . shapeData . flowMeta . jober ;
205+ if ( ! jober . entity . params . exist ( param => param . name === 'context' ) ) {
206+ jober . entity . params . push ( { name : 'context' } ) ;
207+ jober . converter . entity . inputParams . push ( DEFAULT_LOOP_NODE_CONTEXT ) ;
208+ }
209+ } ;
210+
211+ return self ;
212+ } ;
213+
188214
189215/**
190216 * 开始节点兼容性处理器.
@@ -281,43 +307,9 @@ export const endNodeCompatibilityProcessor = (shapeData, graph, pageHandler) =>
281307 if ( inputParam . from !== FROM_TYPE . EXPAND ) {
282308 return ;
283309 }
284-
285- // const values = inputParam.value;
286- //
287- // // 第一个引用若不是大模型,则后续的所有大模型节点enableLog都是false.
288- // // 若第一个引用是对大模型的引用,遍历,后续【连续】的对大模型节点的引用.
289310 const llmNodes = self . pageProcessor . getShapes ( sd => sd . type === 'llmNodeState' ) . map ( ( n , i ) => {
290311 return { index : i , data : n } ;
291312 } ) ;
292- //
293- // let indexes = []; // 记录所有需要输出日志的大模型的下标.
294- // for (let i = 0; i < values.length; i++) {
295- // const input = values[i];
296- //
297- // // 不是reference,或referenceKey不存在,退出循环.
298- // if (input.from !== 'Reference' || !input.referenceKey) {
299- // break;
300- // }
301- //
302- // // 引用的不是大模型,退出循环.
303- // const node = llmNodes.find(n => n.data.id === input.referenceNode);
304- // if (!node) {
305- // break;
306- // }
307- //
308- // // 当前大模型节点的index小于indexes中的值,跳出循环.
309- // if (indexes.length > 0 && node.index < indexes[indexes.length - 1]) {
310- // break;
311- // }
312- //
313- // const chainNodes = self.pageProcessor.getNodesBetween(node.data, self.shapeData);
314- // if (chainNodes.contains(n => n.type === 'conditionNodeCondition' || n.type === 'manualCheckNodeState')) {
315- // break;
316- // }
317- //
318- // indexes.push(node.index);
319- // }
320-
321313 updateLlmFlowMetas ( llmNodes ) ;
322314 } ;
323315
0 commit comments