| @@ -28,9 +28,6 @@ const nodeDefault: NodeDefault<LoopNodeType> = { | |||
| checkValid(payload: LoopNodeType, t: any) { | |||
| let errorMessages = '' | |||
| if (!errorMessages && (!payload.break_conditions || payload.break_conditions.length === 0)) | |||
| errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t('workflow.nodes.loop.breakCondition') }) | |||
| payload.break_conditions!.forEach((condition) => { | |||
| if (!errorMessages && (!condition.variable_selector || condition.variable_selector.length === 0)) | |||
| errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t(`${i18nPrefix}.fields.variable`) }) | |||
| @@ -55,6 +55,7 @@ const Panel: FC<NodePanelProps<LoopNodeType>> = ({ | |||
| <div> | |||
| <Field | |||
| title={<div className='pl-3'>{t(`${i18nPrefix}.breakCondition`)}</div>} | |||
| tooltip={t(`${i18nPrefix}.breakConditionTip`)} | |||
| > | |||
| <ConditionWrap | |||
| nodeId={id} | |||
| @@ -17,12 +17,14 @@ import { getOperators } from './utils' | |||
| import { LogicalOperator } from './types' | |||
| import type { HandleAddCondition, HandleAddSubVariableCondition, HandleRemoveCondition, HandleToggleConditionLogicalOperator, HandleToggleSubVariableConditionLogicalOperator, HandleUpdateCondition, HandleUpdateSubVariableCondition, LoopNodeType } from './types' | |||
| import useIsVarFileAttribute from './use-is-var-file-attribute' | |||
| import { useStore } from '@/app/components/workflow/store' | |||
| const DELIMITER = '@@@@@' | |||
| const useConfig = (id: string, payload: LoopNodeType) => { | |||
| const { nodesReadOnly: readOnly } = useNodesReadOnly() | |||
| const { isNodeInLoop } = useIsNodeInLoop(id) | |||
| const isChatMode = useIsChatMode() | |||
| const conversationVariables = useStore(s => s.conversationVariables) | |||
| const { inputs, setInputs } = useNodeCrud<LoopNodeType>(id, payload) | |||
| @@ -35,7 +37,7 @@ const useConfig = (id: string, payload: LoopNodeType) => { | |||
| const beforeNodes = getBeforeNodesInSameBranch(id) | |||
| const loopChildrenNodes = getLoopNodeChildren(id) | |||
| const canChooseVarNodes = [...beforeNodes, ...loopChildrenNodes] | |||
| const childrenNodeVars = toNodeOutputVars(loopChildrenNodes, isChatMode) | |||
| const childrenNodeVars = toNodeOutputVars(loopChildrenNodes, isChatMode, undefined, [], conversationVariables) | |||
| // single run | |||
| const loopInputKey = `${id}.input_selector` | |||
| @@ -673,6 +673,7 @@ const translation = { | |||
| loop_other: '{{count}} Loops', | |||
| currentLoop: 'Current Loop', | |||
| breakCondition: 'Loop Termination Condition', | |||
| breakConditionTip: 'Only variables within loops with termination conditions and conversation variables can be referenced.', | |||
| loopMaxCount: 'Maximum Loop Count', | |||
| loopMaxCountError: 'Please enter a valid maximum loop count, ranging from 1 to {{maxCount}}', | |||
| errorResponseMethod: 'Error Response Method', | |||
| @@ -674,6 +674,7 @@ const translation = { | |||
| loop_other: '{{count}} 个循环', | |||
| currentLoop: '当前循环', | |||
| breakCondition: '循环终止条件', | |||
| breakConditionTip: '支持引用终止条件循环内的变量和会话变量。', | |||
| loopMaxCount: '最大循环次数', | |||
| loopMaxCountError: '请输入正确的 最大循环次数,范围为 1 到 {{maxCount}}', | |||
| errorResponseMethod: '错误响应方法', | |||