diff --git a/web/src/assets/images/workflow/memory-read.png b/web/src/assets/images/workflow/memory-read.png
new file mode 100644
index 00000000..4b0cdc1d
Binary files /dev/null and b/web/src/assets/images/workflow/memory-read.png differ
diff --git a/web/src/assets/images/workflow/memory-write.png b/web/src/assets/images/workflow/memory-write.png
new file mode 100644
index 00000000..83a50fd4
Binary files /dev/null and b/web/src/assets/images/workflow/memory-write.png differ
diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts
index e679bcee..fc729d98 100644
--- a/web/src/i18n/en.ts
+++ b/web/src/i18n/en.ts
@@ -1798,12 +1798,20 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
"not_contains": 'Does Not Contain',
"startwith": 'Starts With',
"endwith": 'Ends With',
- "eq": '==',
- "ne": '!=',
- "lt": '<',
- "le": '<=',
- "gt": '>',
- "ge": '>=',
+ "eq": 'Equals',
+ "ne": 'Not Equals',
+ num: {
+ "eq": '=',
+ "ne": '≠',
+ "lt": '<',
+ "le": '≤',
+ "gt": '>',
+ "ge": '≥',
+ },
+ boolean: {
+ "eq": 'Is',
+ "ne": 'Is Not',
+ },
else_desc: 'Used to define the logic that should be executed when the if condition is not met.'
},
'http-request': {
@@ -1844,12 +1852,17 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
loop: {
cycle_vars: 'Loop Variables',
condition: 'Loop Termination Condition',
+ max_loop: 'Maximum Loop Count',
},
assigner: {
assignments: 'Variables',
- cover: 'Overwrite',
+ cover: 'Override',
assign: 'Set',
- clear: 'Clear'
+ clear: 'Clear',
+ add: '+=',
+ subtract: '-=',
+ multiply: '*=',
+ divide: '/=',
},
iteration: {
input: 'Input Variable',
diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts
index abb95a79..b6972c1f 100644
--- a/web/src/i18n/zh.ts
+++ b/web/src/i18n/zh.ts
@@ -1898,12 +1898,20 @@ export const zh = {
"not_contains": '不包含',
"startwith": '开始是',
"endwith": '结束是',
- "eq": '==',
- "ne": '!=',
- "lt": '<',
- "le": '<=',
- "gt": '>',
- "ge": '>=',
+ "eq": '是',
+ "ne": '不是',
+ num: {
+ "eq": '=',
+ "ne": '≠',
+ "lt": '<',
+ "le": '≤',
+ "gt": '>',
+ "ge": '≥',
+ },
+ boolean: {
+ "eq": '是',
+ "ne": '不是',
+ },
else_desc: '用于定义当 if 条件不满足时应执行的逻辑。'
},
'http-request': {
@@ -1944,12 +1952,17 @@ export const zh = {
loop: {
cycle_vars: '循环变量',
condition: '循环终止条件',
+ max_loop: '最大循环次数',
},
assigner: {
assignments: '变量',
cover: '覆盖',
assign: '设置',
- clear: '清空'
+ clear: '清空',
+ add: '+=',
+ subtract: '-=',
+ multiply: '*=',
+ divide: '/=',
},
iteration: {
input: '输入变量',
diff --git a/web/src/views/ToolManagement/Inner.tsx b/web/src/views/ToolManagement/Inner.tsx
index d256d6c7..6f85e1f7 100644
--- a/web/src/views/ToolManagement/Inner.tsx
+++ b/web/src/views/ToolManagement/Inner.tsx
@@ -4,10 +4,9 @@ import {
Col,
Tag,
List,
- Space
+ Flex
} from 'antd';
import { EyeOutlined } from '@ant-design/icons';
-import clsx from 'clsx'
import { useTranslation } from 'react-i18next';
import dayjs, { type Dayjs } from 'dayjs'
@@ -103,9 +102,9 @@ const Inner: React.FC<{ getStatusTag: (status: string) => ReactNode }> = ({ getS
{t(`tool.${item.config_data.tool_class}_features`)}
-
+
{InnerConfigData[item.config_data.tool_class].features.map(vo => { t(`tool.${vo}`) }) }
-
+
{item.config_data.tool_class === 'DateTimeTool'
?
diff --git a/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx b/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx
index 571f1e4e..fabe45ba 100644
--- a/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx
+++ b/web/src/views/Workflow/components/AddChatVariable/ChatVariableModal.tsx
@@ -26,7 +26,6 @@ const ChatVariableModal = forwardRef
();
const [loading, setLoading] = useState(false)
const [editIndex, setEditIndex] = useState(undefined)
- const typeValue = Form.useWatch('type', form);
// 封装取消方法,添加关闭弹窗逻辑
const handleClose = () => {
diff --git a/web/src/views/Workflow/components/Editor/plugin/CharacterCountPlugin.tsx b/web/src/views/Workflow/components/Editor/plugin/CharacterCountPlugin.tsx
index 963f824b..ed07392d 100644
--- a/web/src/views/Workflow/components/Editor/plugin/CharacterCountPlugin.tsx
+++ b/web/src/views/Workflow/components/Editor/plugin/CharacterCountPlugin.tsx
@@ -14,18 +14,23 @@ const CharacterCountPlugin = ({ setCount, onChange }: { setCount: (count: number
let serializedContent = '';
// Traverse all nodes and serialize properly
+ const paragraphs: string[] = [];
root.getChildren().forEach(child => {
if ($isParagraphNode(child)) {
+ let paragraphContent = '';
child.getChildren().forEach(node => {
if ($isVariableNode(node)) {
- serializedContent += node.getTextContent();
+ paragraphContent += node.getTextContent();
} else {
- serializedContent += node.getTextContent();
+ paragraphContent += node.getTextContent();
}
});
+ paragraphs.push(paragraphContent);
}
});
+ serializedContent = paragraphs.join('\n');
+
setCount(serializedContent.length);
onChange?.(serializedContent);
});
diff --git a/web/src/views/Workflow/components/Editor/plugin/InitialValuePlugin.tsx b/web/src/views/Workflow/components/Editor/plugin/InitialValuePlugin.tsx
index 4059b300..93197150 100644
--- a/web/src/views/Workflow/components/Editor/plugin/InitialValuePlugin.tsx
+++ b/web/src/views/Workflow/components/Editor/plugin/InitialValuePlugin.tsx
@@ -26,6 +26,7 @@ const InitialValuePlugin: React.FC = ({ value, options
parts.forEach(part => {
const match = part.match(/^\{\{([^.]+)\.([^}]+)\}\}$/);
const contextMatch = part.match(/^\{\{context\}\}$/);
+ const conversationMatch = part.match(/^\{\{conv\.([^}]+)\}\}$/);
// 匹配{{context}}格式
if (contextMatch) {
@@ -38,6 +39,20 @@ const InitialValuePlugin: React.FC = ({ value, options
return
}
+ // 匹配{{conv.xx}}格式
+ if (conversationMatch) {
+ const [_, variableName] = conversationMatch;
+ const conversationSuggestion = options.find(s =>
+ s.group === 'CONVERSATION' && s.label === variableName
+ );
+ if (conversationSuggestion) {
+ paragraph.append($createVariableNode(conversationSuggestion));
+ } else {
+ paragraph.append($createTextNode(part));
+ }
+ return
+ }
+
// 匹配普通变量{{nodeId.label}}格式
if (match) {
const [_, nodeId, label] = match;
diff --git a/web/src/views/Workflow/components/Nodes/AddNode.tsx b/web/src/views/Workflow/components/Nodes/AddNode.tsx
index a2f6d930..973a503c 100644
--- a/web/src/views/Workflow/components/Nodes/AddNode.tsx
+++ b/web/src/views/Workflow/components/Nodes/AddNode.tsx
@@ -13,13 +13,15 @@ const AddNode: ReactShapeConfig['component'] = ({ node, graph }) => {
const handleNodeSelect = (selectedNodeType: any) => {
const parentBBox = node.getBBox();
const cycleId = data.cycle;
-
+
+ const id = `${selectedNodeType.type.replace(/-/g, '_') }_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
const newNode = graph.addNode({
...(graphNodeLibrary[selectedNodeType.type] || graphNodeLibrary.default),
x: parentBBox.x,
y: parentBBox.y,
+ id,
data: {
- id: `${selectedNodeType.type}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
+ id,
type: selectedNodeType.type,
icon: selectedNodeType.icon,
name: t(`workflow.${selectedNodeType.type}`),
diff --git a/web/src/views/Workflow/components/Nodes/LoopNode.tsx b/web/src/views/Workflow/components/Nodes/LoopNode.tsx
index b0b8d4ce..37feb2dc 100644
--- a/web/src/views/Workflow/components/Nodes/LoopNode.tsx
+++ b/web/src/views/Workflow/components/Nodes/LoopNode.tsx
@@ -75,12 +75,15 @@ const LoopNode: ReactShapeConfig['component'] = ({ node, graph }) => {
const parentBBox = node.getBBox();
const centerX = parentBBox.x + 24; // 默认节点宽度的一半
const centerY = parentBBox.y + 50; // 默认节点高度的一半
-
+
+ const cycleStartNodeId = `cycle_start_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
const cycleStartNode = graph.addNode({
...graphNodeLibrary.cycleStart,
x: centerX,
y: centerY,
+ id: cycleStartNodeId,
data: {
+ id: cycleStartNodeId,
type: 'cycle-start',
parentId: node.id,
isDefault: true, // 标记为默认节点,不可删除
diff --git a/web/src/views/Workflow/components/PortClickHandler.tsx b/web/src/views/Workflow/components/PortClickHandler.tsx
index 0be6fba1..9a644438 100644
--- a/web/src/views/Workflow/components/PortClickHandler.tsx
+++ b/web/src/views/Workflow/components/PortClickHandler.tsx
@@ -43,12 +43,14 @@ const PortClickHandler: React.FC = ({ graph }) => {
const newY = sourceBBox.y;
// 创建新节点
+ const id = `${selectedNodeType.type.replace(/-/g, '_')}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
const newNode = graph.addNode({
...(graphNodeLibrary[selectedNodeType.type] || graphNodeLibrary.default),
x: newX,
y: newY,
+ id,
data: {
- id: `${selectedNodeType.type}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
+ id,
type: selectedNodeType.type,
icon: selectedNodeType.icon,
name: t(`workflow.${selectedNodeType.type}`),
diff --git a/web/src/views/Workflow/components/Properties/AssignmentList/index.tsx b/web/src/views/Workflow/components/Properties/AssignmentList/index.tsx
index 34c133c7..eac3775f 100644
--- a/web/src/views/Workflow/components/Properties/AssignmentList/index.tsx
+++ b/web/src/views/Workflow/components/Properties/AssignmentList/index.tsx
@@ -1,6 +1,6 @@
import { type FC } from 'react'
import { useTranslation } from 'react-i18next';
-import { Form, Input, Button, Row, Col, Select } from 'antd'
+import { Form, Input, Row, Col, Select, InputNumber, Radio } from 'antd'
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import type { Suggestion } from '../../Editor/plugin/AutocompletePlugin'
import VariableSelect from '../VariableSelect'
@@ -11,6 +11,23 @@ interface AssignmentListProps {
options: Suggestion[];
}
+const operationsObj = {
+ number: [
+ { value: 'cover', label: 'workflow.config.assigner.cover' },
+ { value: 'clear', label: 'workflow.config.assigner.clear' },
+ { value: 'assign', label: 'workflow.config.assigner.assign' },
+ { value: 'add', label: 'workflow.config.assigner.add' },
+ { value: 'subtract', label: 'workflow.config.assigner.subtract' },
+ { value: 'multiply', label: 'workflow.config.assigner.multiply' },
+ { value: 'divide', label: 'workflow.config.assigner.divide' },
+ ],
+ default: [
+ { value: 'cover', label: 'workflow.config.assigner.cover' },
+ { value: 'clear', label: 'workflow.config.assigner.clear' },
+ { value: 'assign', label: 'workflow.config.assigner.assign' },
+ ],
+}
+
const AssignmentList: FC = ({
parentName,
options = [],
@@ -27,6 +44,11 @@ const AssignmentList: FC = ({
add({ operation: 'cover'})} />
{fields.map(({ key, name, ...restField }) => {
+ const variableSelector = form.getFieldValue([parentName, name, 'variable_selector']);
+ const selectedOption = options.find(option => `{{${option.value}}}` === variableSelector);
+ const dataType = selectedOption?.dataType;
+ const operationOptions = dataType === 'number' ? operationsObj.number : operationsObj.default;
+
return (
@@ -50,11 +72,10 @@ const AssignmentList: FC = ({
noStyle
>
)
diff --git a/web/src/views/Workflow/components/Properties/ConditionList/index.tsx b/web/src/views/Workflow/components/Properties/ConditionList/index.tsx
index 5f2a0bcb..2f544281 100644
--- a/web/src/views/Workflow/components/Properties/ConditionList/index.tsx
+++ b/web/src/views/Workflow/components/Properties/ConditionList/index.tsx
@@ -1,7 +1,6 @@
import { type FC } from 'react'
-import clsx from 'clsx'
import { useTranslation } from 'react-i18next';
-import { Form, Button, Select, Space, Row, Col, Divider } from 'antd'
+import { Form, Button, Select, Row, Col, InputNumber, Radio, type SelectProps } from 'antd'
import { DeleteOutlined } from '@ant-design/icons';
import type { Suggestion } from '../../Editor/plugin/AutocompletePlugin'
@@ -10,7 +9,7 @@ import Editor from '../../Editor'
interface Case {
logical_operator: 'and' | 'or';
- expressions: Array<{ left: string; comparison_operator: string; right: string; }>
+ expressions: Array<{ left: string; comparison_operator: string; right: string; input_type: string; }>
}
interface CaseListProps {
@@ -22,36 +21,63 @@ interface CaseListProps {
graphRef?: any;
addBtnText?: string;
}
-const operatorList = [
- "empty",
- "not_empty",
- "contains",
- "not_contains",
- "startwith",
- "endwith",
- "eq",
- "ne",
- "lt",
- "le",
- "gt",
- "ge"
-]
+const operatorsObj: { [key: string]: SelectProps['options'] } = {
+ default: [
+ { value: 'empty', label: 'workflow.config.if-else.empty' },
+ { value: 'not_empty', label: 'workflow.config.if-else.not_empty' },
+ { value: 'contains', label: 'workflow.config.if-else.contains' },
+ { value: 'not_contains', label: 'workflow.config.if-else.not_contains' },
+ { value: 'startwith', label: 'workflow.config.if-else.startwith' },
+ { value: 'endwith', label: 'workflow.config.if-else.endwith' },
+ { value: 'eq', label: 'workflow.config.if-else.eq' },
+ { value: 'ne', label: 'workflow.config.if-else.ne' },
+ ],
+ number: [
+ { value: 'eq', label: 'workflow.config.if-else.num.eq' },
+ { value: 'ne', label: 'workflow.config.if-else.num.ne' },
+ { value: 'lt', label: 'workflow.config.if-else.num.lt' },
+ { value: 'le', label: 'workflow.config.if-else.num.le' },
+ { value: 'gt', label: 'workflow.config.if-else.num.gt' },
+ { value: 'ge', label: 'workflow.config.if-else.num.ge' },
+ { value: 'empty', label: 'workflow.config.if-else.empty' },
+ { value: 'not_empty', label: 'workflow.config.if-else.not_empty' },
+ ],
+ boolean: [
+ { value: 'eq', label: 'workflow.config.if-else.boolean.eq' },
+ { value: 'ne', label: 'workflow.config.if-else.boolean.ne' },
+ ]
+}
const ConditionList: FC
= ({
- value,
options,
parentName,
- onChange,
}) => {
const { t } = useTranslation();
+ const form = Form.useFormInstance();
+
+ const handleLeftFieldChange = (index: number, newValue: string) => {
+ form.setFieldsValue({
+ [parentName]: {
+ expressions: {
+ [index]: {
+ left: newValue,
+ comparison_operator: undefined,
+ right: undefined,
+ input_type: undefined
+ }
+ }
+ }
+ });
+ };
+
+ const handleInputTypeChange = (index: number) => {
+ form.setFieldValue([parentName, 'expressions', index, 'right'], undefined);
+ };
const handleChangeLogicalOperator = () => {
- if (!value) return;
- onChange && onChange({
- logical_operator: value.logical_operator === 'and' ? 'or' : 'and',
- expressions: value.expressions || []
- })
- }
+ const currentValue = form.getFieldValue([parentName, 'logical_operator']);
+ form.setFieldValue([parentName, 'logical_operator'], currentValue === 'and' ? 'or' : 'and');
+ };
return (
<>
@@ -59,8 +85,16 @@ const ConditionList: FC = ({
{fields.map((field, index) => {
- const currentOperator = value?.expressions?.[index]?.comparison_operator;
+ const expressions = form.getFieldValue([parentName, 'expressions']) || [];
+ const currentExpression = expressions[index] || {};
+ const currentOperator = currentExpression.comparison_operator;
const hideRightField = currentOperator === 'empty' || currentOperator === 'not_empty';
+ const leftFieldValue = currentExpression.left;
+ const leftFieldOption = options.find(option => `{{${option.value}}}` === leftFieldValue);
+ const leftFieldType = leftFieldOption?.dataType;
+ const operatorList = operatorsObj[leftFieldType || 'default'] || operatorsObj.default || [];
+ const inputType = leftFieldType === 'number' ? currentExpression.input_type : undefined;
+ const logicalOperator = form.getFieldValue([parentName, 'logical_operator']);
return (
@@ -68,7 +102,7 @@ const ConditionList: FC
= ({
- {value?.logical_operator}
+ {logicalOperator}
>)}
@@ -82,6 +116,7 @@ const ConditionList: FC = ({
size="small"
allowClear={false}
popupMatchSelectWidth={false}
+ onChange={(val) => handleLeftFieldChange(index, val)}
/>
@@ -89,9 +124,9 @@ const ConditionList: FC = ({
diff --git a/web/src/views/Workflow/components/Properties/CycleVarsList/index.tsx b/web/src/views/Workflow/components/Properties/CycleVarsList/index.tsx
index 367e8483..c05cce25 100644
--- a/web/src/views/Workflow/components/Properties/CycleVarsList/index.tsx
+++ b/web/src/views/Workflow/components/Properties/CycleVarsList/index.tsx
@@ -65,7 +65,7 @@ const CycleVarsList: FC
= ({
label: `${childData.name || childData.type}.${key}`,
type: 'output',
dataType: 'string',
- value: `{{${childData.id}.${key}}}`,
+ value: `${childData.id}.${key}`,
nodeData: childData
});
}
diff --git a/web/src/views/Workflow/components/Properties/GroupVariableList/index.tsx b/web/src/views/Workflow/components/Properties/GroupVariableList/index.tsx
index fccce21b..2b2db0f7 100644
--- a/web/src/views/Workflow/components/Properties/GroupVariableList/index.tsx
+++ b/web/src/views/Workflow/components/Properties/GroupVariableList/index.tsx
@@ -25,7 +25,6 @@ const GroupVariableList: FC = ({
{t('workflow.config.var-aggregator.variable')}
@@ -34,9 +33,8 @@ const GroupVariableList: FC = ({
= ({
{...restField}
name={[name, 'value']}
noStyle
- rules={[{ required: true, message: 'Missing last name' }]}
>
= ({
const [rows, setRows] = useState([]);
useEffect(() => {
- console.log('EditableTable value', value)
if (Array.isArray(value)) {
setRows([...value])
} else if (value && Object.keys(value).length > 0) {
- // Only update if rows are empty or significantly different
- const valueEntries = Object.entries(value)
- if (rows.length === 0 || rows.length !== valueEntries.length) {
- setRows(valueEntries.map(([key, val], index) => {
- console.log('val', val)
- return {
- key: index.toString(),
- name: key || '',
- value: val || '',
- type: typeOptions.length > 0 ? typeOptions[0].value : undefined
- }
- }))
- }
+ setRows(Object.entries(value).map(([key, val], index) => ({
+ key: index.toString(),
+ name: key || '',
+ value: val || '',
+ type: typeOptions.length > 0 ? typeOptions[0].value : undefined
+ })))
} else {
setRows([])
}
- }, [JSON.stringify(value), typeOptions.length])
+ }, [value, typeOptions])
const handleChange = (key: string, field: 'name' | 'value' | 'type', val: string) => {
- const newRows = [...rows.map(row =>
+ const newRows = rows.map(row =>
row.key === key ? { ...row, [field]: val } : row
- )];
-
+ );
setRows(newRows);
onChange?.(newRows);
};
const handleAdd = () => {
- const newKey = Date.now().toString();
- if (typeOptions.length) {
- setRows([...rows, { key: newKey, name: '', value: '', type: typeOptions[0].value }]);
- } else {
- setRows([...rows, { key: newKey, name: '', value: '' }]);
- }
+ const newRow: TableRow = {
+ key: Date.now().toString(),
+ name: '',
+ value: '',
+ ...(typeOptions.length > 0 && { type: typeOptions[0].value })
+ };
+ const newRows = [...rows, newRow];
+ setRows(newRows);
+ onChange?.(newRows);
};
- const handleDelete = (key: string, index: number) => {
- console.log('index', index)
-
- if (rows.length === 1) {
- setRows([]);
- onChange?.([]);
- } else {
- const newRows = rows.filter(row => row.key !== key);
- setRows(newRows);
- onChange?.(newRows);
- }
+ const handleDelete = (key: string) => {
+ const newRows = rows.filter(row => row.key !== key);
+ setRows(newRows);
+ onChange?.(newRows);
};
- const columns = typeOptions?.length > 0 ? [
- {
- title: t('workflow.config.name'),
- dataIndex: 'name',
- width: '45%',
- render: (text: string, record: TableRow) => (
- handleChange(record.key, 'name', value)}
- />
- ),
- },
- {
- title: t('workflow.config.type'),
- dataIndex: 'type',
- width: '20%',
- render: (text: string, record: TableRow) => (
- {
- console.log('value record', value)
- handleChange(record.key, 'type', value)
- }}
- />
- ),
- },
- {
- title: t('workflow.config.value'),
+ const columns = useMemo(() => {
+ const baseColumns = [
+ {
+ title: typeOptions.length > 0 ? t('workflow.config.name') : '键',
+ dataIndex: 'name',
+ width: typeOptions.length > 0 ? '35%' : '45%',
+ render: (text: string, record: TableRow) => (
+ handleChange(record.key, 'name', value || '')}
+ />
+ ),
+ }
+ ];
+
+ if (typeOptions.length > 0) {
+ baseColumns.push({
+ title: t('workflow.config.type'),
+ dataIndex: 'type',
+ width: '20%',
+ render: (text: string, record: TableRow) => (
+ handleChange(record.key, 'type', value)}
+ />
+ ),
+ });
+ }
+
+ baseColumns.push({
+ title: typeOptions.length > 0 ? t('workflow.config.value') : '值',
dataIndex: 'value',
- width: '45%',
+ width: typeOptions.length > 0 ? '35%' : '45%',
render: (text: string, record: TableRow) => {
if (record.type === 'file') {
-
return (
{
- console.log('value record', value)
- handleChange(record.key, 'value', value)
- }}
+ onChange={(value) => handleChange(record.key, 'value', value || '')}
/>
)
}
@@ -140,78 +126,41 @@ const EditableTable: React.FC = ({
value={text}
height={32}
variant="outlined"
- onChange={(value) => {
- console.log('value record', value)
- handleChange(record.key, 'value', value)
- }}
+ onChange={(value) => handleChange(record.key, 'value', value || '')}
/>
)
},
- },
- {
+ });
+
+ baseColumns.push({
title: '',
+ dataIndex: 'actions',
width: '10%',
- render: (_: any, record: TableRow, index: number) => (
+ render: (_: any, record: TableRow) => (
}
- onClick={() => handleDelete(record.key, index)}
+ onClick={() => handleDelete(record.key)}
/>
),
- },
- ] : [
- {
- title: '键',
- dataIndex: 'name',
- width: '45%',
- render: (text: string, record: TableRow) => (
- handleChange(record.key, 'name', value)}
- />
- ),
- },
- {
- title: '值',
- dataIndex: 'value',
- width: '45%',
- render: (text: string, record: TableRow) => (
- handleChange(record.key, 'value', value)}
- />
- ),
- },
- {
- title: '',
- width: '10%',
- render: (_: any, record: TableRow, index: number) => (
- }
- onClick={() => handleDelete(record.key, index)}
- />
- ),
- },
- ];
+ });
+
+ return baseColumns;
+ }, [typeOptions, options, t]);
return (
- {title &&
-
{title}
-
}
- onClick={handleAdd}
- size="small"
- />
-
}
+ {title && (
+
+
{title}
+
}
+ onClick={handleAdd}
+ size="small"
+ />
+
+ )}
= ({
locale={{ emptyText: }}
scroll={{ x: 'max-content' }}
/>
- {!title &&
+ {!title && (
+{t('common.add')}
- }
+ )}
);
};
diff --git a/web/src/views/Workflow/components/Properties/HttpRequest/index.tsx b/web/src/views/Workflow/components/Properties/HttpRequest/index.tsx
index 3b855c48..a007d75e 100644
--- a/web/src/views/Workflow/components/Properties/HttpRequest/index.tsx
+++ b/web/src/views/Workflow/components/Properties/HttpRequest/index.tsx
@@ -1,6 +1,6 @@
-import { type FC, useEffect, useRef } from "react";
+import { type FC, useRef } from "react";
import { useTranslation } from 'react-i18next'
-import { Form, Row, Col, Select, Button, Divider, InputNumber, Switch, Input, Slider } from 'antd'
+import { Form, Row, Col, Select, Button, Divider, InputNumber, Switch, Input } from 'antd'
import Editor from '../../Editor'
import type { Suggestion } from '../../Editor/plugin/AutocompletePlugin'
import AuthConfigModal from './AuthConfigModal'
diff --git a/web/src/views/Workflow/components/Properties/Knowledge/Knowledge.tsx b/web/src/views/Workflow/components/Properties/Knowledge/Knowledge.tsx
index aeafb67c..af89f7d2 100644
--- a/web/src/views/Workflow/components/Properties/Knowledge/Knowledge.tsx
+++ b/web/src/views/Workflow/components/Properties/Knowledge/Knowledge.tsx
@@ -128,29 +128,32 @@ const Knowledge: FC<{value?: KnowledgeConfig; onChange?: (config: KnowledgeConfi
(
-
-
-
- {item.name}
-
- {item.status === 1 ? t('common.enable') : item.status === 0 ? t('common.disabled') : t('common.deleted')}
-
-
{t('application.contains', {include_count: item.doc_num})}
+ renderItem={(item) => {
+ if (!item.id) return null
+ return (
+
+
+
+ {item.name}
+
+ {item.status === 1 ? t('common.enable') : item.status === 0 ? t('common.disabled') : t('common.deleted')}
+
+
{t('application.contains', {include_count: item.doc_num})}
+
+
+ handleEditKnowledge(item)}
+ >
+ handleDeleteKnowledge(item.id)}
+ >
+
-
- handleEditKnowledge(item)}
- >
- handleDeleteKnowledge(item.id)}
- >
-
-
-
- )}
+
+ )
+ }}
/>
}
{/* 全局设置 */}
diff --git a/web/src/views/Workflow/components/Properties/MappingList/index.tsx b/web/src/views/Workflow/components/Properties/MappingList/index.tsx
index b2066681..b8f7caf0 100644
--- a/web/src/views/Workflow/components/Properties/MappingList/index.tsx
+++ b/web/src/views/Workflow/components/Properties/MappingList/index.tsx
@@ -1,12 +1,15 @@
import React from 'react';
import { useTranslation } from 'react-i18next'
import { MinusCircleOutlined } from '@ant-design/icons';
-import { Button, Form, Input, Space } from 'antd';
+import { Button, Form, Input, Space, Row, Col } from 'antd';
+import type { Suggestion } from '../../Editor/plugin/AutocompletePlugin'
+import VariableSelect from '../VariableSelect'
interface MappingListProps {
name: string;
+ options: Suggestion[];
}
-const MappingList: React.FC
= ({ name }) => {
+const MappingList: React.FC = ({ name, options }) => {
const { t } = useTranslation()
return (
<>
@@ -14,23 +17,33 @@ const MappingList: React.FC = ({ name }) => {
{(fields, { add, remove }) => (
<>
{fields.map(({ key, name, ...restField }) => (
-
-
-
-
-
-
-
- remove(name)} />
-
+
+
+
+
+
+
+
+
+
+
+
+
+ remove(name)} />
+
+
))}
add()} block>
diff --git a/web/src/views/Workflow/components/Properties/MessageEditor.tsx b/web/src/views/Workflow/components/Properties/MessageEditor.tsx
index 9ced9c79..cd9dd17c 100644
--- a/web/src/views/Workflow/components/Properties/MessageEditor.tsx
+++ b/web/src/views/Workflow/components/Properties/MessageEditor.tsx
@@ -29,15 +29,15 @@ const MessageEditor: FC = ({
}) => {
const { t } = useTranslation()
const form = Form.useFormInstance();
- const values = form.getFieldsValue()
+ const values = Form.useWatch([], form);
// 检查是否已经使用了context变量,将已使用的context设置为disabled
const processedOptions = useMemo(() => {
- if (!isArray || !values[parentName]) return options;
+ if (!isArray || !values?.[parentName]) return options;
// 获取所有消息内容
const allContents = values[parentName]
- .map((msg: any) => msg.content || '')
+ .map((msg: any) => msg?.content || '')
.join(' ');
// 将已使用的context变量标记为disabled
@@ -50,83 +50,74 @@ const MessageEditor: FC = ({
}, [options, values, parentName, isArray]);
const handleAdd = (add: FormListOperation['add']) => {
- const list = values[parentName];
- const lastRole = list[list.length - 1].role
+ const list = values?.[parentName] || [];
+ const lastRole = list.length > 0 ? list[list.length - 1]?.role : 'ASSISTANT';
add({
role: lastRole === 'USER' ? 'ASSISTANT' : 'USER',
- content: undefined
- })
+ content: ''
+ });
+ };
+
+ if (!isArray) {
+ return (
+
+
+
+ {title ?? t('workflow.answerDesc')}
+
+
+
+
+
+
+ );
}
return (
-
+ )}
+
);
};
diff --git a/web/src/views/Workflow/components/Properties/index.tsx b/web/src/views/Workflow/components/Properties/index.tsx
index 7f3db76b..d179483a 100644
--- a/web/src/views/Workflow/components/Properties/index.tsx
+++ b/web/src/views/Workflow/components/Properties/index.tsx
@@ -85,15 +85,6 @@ const Properties: FC = ({
const { id, knowledge_retrieval, group, group_names, ...rest } = values
const { knowledge_bases = [], ...restKnowledgeConfig } = (knowledge_retrieval as any) || {}
- let groupNames: Record | string[] = {}
-
- if (group && group_names?.length) {
- group_names.forEach(vo => {
- (groupNames as Record)[vo.key] = vo.value
- })
- } else if (!group) {
- groupNames = group_names?.[0]?.value || []
- }
let allRest = {
...rest,
...restKnowledgeConfig,
@@ -107,7 +98,14 @@ const Properties: FC = ({
Object.keys(values).forEach(key => {
if (selectedNode.data?.config?.[key]) {
- selectedNode.data.config[key].defaultValue = values[key]
+ // Create a deep copy to avoid reference sharing between nodes
+ if (!selectedNode.data.config[key]) {
+ selectedNode.data.config[key] = {};
+ }
+ selectedNode.data.config[key] = {
+ ...selectedNode.data.config[key],
+ defaultValue: values[key]
+ };
}
})
@@ -194,7 +192,7 @@ const Properties: FC = ({
const allPreviousNodeIds = getAllPreviousNodes(selectedNode.id);
const childNodeIds = getChildNodes(selectedNode.id);
- console.log('childNodeIds', childNodeIds)
+ console.log('childNodeIds', selectedNode, childNodeIds)
const allRelevantNodeIds = [...allPreviousNodeIds, ...childNodeIds];
allRelevantNodeIds.forEach(nodeId => {
@@ -219,7 +217,7 @@ const Properties: FC = ({
label: variable.name,
type: 'variable',
dataType: variable.type,
- value: `{{${nodeId}.${variable.name}}}`,
+ value: `${node.getData().id}.${variable.name}`,
nodeData: nodeData,
});
}
@@ -249,7 +247,7 @@ const Properties: FC = ({
label: 'output',
type: 'variable',
dataType: 'String',
- value: `${nodeId}.output`,
+ value: `${node.getData().id}.output`,
nodeData: nodeData,
});
}
@@ -263,7 +261,104 @@ const Properties: FC = ({
label: 'message',
type: 'variable',
dataType: 'array[object]',
- value: `${nodeId}.message`,
+ value: `${node.getData().id}.message`,
+ nodeData: nodeData,
+ });
+ }
+ break
+ case 'parameter-extractor':
+ const successKey = `${nodeId}___is_success`;
+ const reasonKey = `${nodeId}___reason`;
+ if (!addedKeys.has(successKey)) {
+ addedKeys.add(successKey);
+ variableList.push({
+ key: successKey,
+ label: '__is_success',
+ type: 'variable',
+ dataType: 'number',
+ value: `${node.getData().id}.__is_success`,
+ nodeData: nodeData,
+ });
+ }
+ if (!addedKeys.has(reasonKey)) {
+ addedKeys.add(reasonKey);
+ variableList.push({
+ key: reasonKey,
+ label: '__reason',
+ type: 'variable',
+ dataType: 'string',
+ value: `${node.getData().id}.__reason`,
+ nodeData: nodeData,
+ });
+ }
+ // Add params variables
+ const paramsList = nodeData.config?.params?.defaultValue || [];
+ paramsList.forEach((param: any) => {
+ if (!param || !param?.name) return;
+ const paramKey = `${nodeId}_${param.name}`;
+ if (!addedKeys.has(paramKey)) {
+ addedKeys.add(paramKey);
+ variableList.push({
+ key: paramKey,
+ label: param.name,
+ type: 'variable',
+ dataType: param.type || 'string',
+ value: `${node.getData().id}.${param.name}`,
+ nodeData: nodeData,
+ });
+ }
+ });
+ break
+ case 'var-aggregator':
+ const varAggregatorKey = `${nodeId}_output`;
+ if (!addedKeys.has(varAggregatorKey)) {
+ addedKeys.add(varAggregatorKey);
+ variableList.push({
+ key: varAggregatorKey,
+ label: 'output',
+ type: 'variable',
+ dataType: 'string',
+ value: `${node.getData().id}.output`,
+ nodeData: nodeData,
+ });
+ }
+ break
+ case 'http-request':
+ const httpBodyKey = `${nodeId}_body`;
+ const httpStatusKey = `${nodeId}_status_code`;
+ if (!addedKeys.has(httpBodyKey)) {
+ addedKeys.add(httpBodyKey);
+ variableList.push({
+ key: httpBodyKey,
+ label: 'body',
+ type: 'variable',
+ dataType: 'string',
+ value: `${node.getData().id}.body`,
+ nodeData: nodeData,
+ });
+ }
+ if (!addedKeys.has(httpStatusKey)) {
+ addedKeys.add(httpStatusKey);
+ variableList.push({
+ key: httpStatusKey,
+ label: 'status_code',
+ type: 'variable',
+ dataType: 'number',
+ value: `${node.getData().id}.status_code`,
+ nodeData: nodeData,
+ });
+ }
+ break
+ case 'jinja-render':
+ const jinjaOutputKey = `${nodeId}_output`;
+ if (!addedKeys.has(jinjaOutputKey)) {
+ addedKeys.add(jinjaOutputKey);
+ variableList.push({
+ key: jinjaOutputKey,
+ label: 'output',
+ type: 'variable',
+ dataType: 'string',
+ value: `${node.getData().id}.output`,
nodeData: nodeData,
});
}
@@ -283,7 +378,7 @@ const Properties: FC = ({
label: variable.name,
type: 'variable',
dataType: variable.type,
- value: `conversation.${variable.name}`,
+ value: `conv.${variable.name}`,
nodeData: { type: 'CONVERSATION', name: 'CONVERSATION', icon: '' },
group: 'CONVERSATION'
});
@@ -387,7 +482,7 @@ const Properties: FC = ({
label: 'context',
type: 'variable',
dataType: 'String',
- value: `{{context}}`,
+ value: `context`,
nodeData: selectedNode.getData(),
isContext: true,
});
@@ -476,7 +571,7 @@ const Properties: FC = ({
-
+
)
@@ -583,7 +678,7 @@ const Properties: FC = ({
?
: config.type === 'select'
? ({ ...vo, label: t(vo.label) })) : config.options}
+ options={config.needTranslation ? config.options?.map(vo => ({ ...vo, label: t(vo.label) })) : config.options}
placeholder={t('common.pleaseSelect')}
/>
: config.type === 'inputNumber'
@@ -635,7 +730,7 @@ const Properties: FC = ({
}
/>
: config.type === 'switch'
- ?
+ ? { form.setFieldValue('group_names', []) } : undefined} />
: config.type === 'categoryList'
?
: config.type === 'conditionList'
diff --git a/web/src/views/Workflow/constant.ts b/web/src/views/Workflow/constant.ts
index 101eb71e..c398eb70 100644
--- a/web/src/views/Workflow/constant.ts
+++ b/web/src/views/Workflow/constant.ts
@@ -39,6 +39,9 @@ import processEvolutionIcon from '@/assets/images/workflow/process_evolution.png
import questionClassifierIcon from '@/assets/images/workflow/question-classifier.png'
import breakIcon from '@/assets/images/workflow/break.png'
import assignerIcon from '@/assets/images/workflow/assigner.png'
+import memoryReadIcon from '@/assets/images/workflow/memory-read.png'
+import memoryWriteIcon from '@/assets/images/workflow/memory-write.png'
+
import { memoryConfigListUrl } from '@/api/memory'
import { getModelListUrl } from '@/api/models'
@@ -159,6 +162,7 @@ export const nodeLibrary: NodeLibrary[] = [
},
text: {
type: 'variableList',
+ filterLoopIterationVars: true
},
params: {
type: 'paramList',
@@ -174,8 +178,7 @@ export const nodeLibrary: NodeLibrary[] = [
{
category: "cognitiveUpgrading",
nodes: [
- {
- type: "memory-read", icon: memoryEnhancementIcon,
+ { type: "memory-read", icon: memoryReadIcon,
config: {
message: {
type: 'messageEditor',
@@ -198,7 +201,7 @@ export const nodeLibrary: NodeLibrary[] = [
}
}
},
- { type: "memory-write", icon: memoryEnhancementIcon,
+ { type: "memory-write", icon: memoryWriteIcon,
config: {
message: {
type: 'messageEditor',
@@ -272,6 +275,7 @@ export const nodeLibrary: NodeLibrary[] = [
},
parallel: {
type: 'switch',
+ defaultValue: false
},
parallel_count: {
type: 'slider',
@@ -284,6 +288,7 @@ export const nodeLibrary: NodeLibrary[] = [
},
flatten: { // 扁平化输出
type: 'switch',
+ defaultValue: false
},
output: {
type: 'variableList',
@@ -304,6 +309,13 @@ export const nodeLibrary: NodeLibrary[] = [
expressions: []
}
},
+ max_loop: {
+ type: 'slider',
+ min: 1,
+ max: 100,
+ step: 1,
+ defaultValue: 10
+ },
}
},
{ type: "cycle-start", icon: loopIcon },
@@ -317,7 +329,7 @@ export const nodeLibrary: NodeLibrary[] = [
},
group_names: {
type: 'groupVariableList',
- defaultValue: [{ key: 'Group1', value: []}]
+ defaultValue: [],
}
}
},
diff --git a/web/src/views/Workflow/hooks/useWorkflowGraph.ts b/web/src/views/Workflow/hooks/useWorkflowGraph.ts
index 60c14f6d..98f37f12 100644
--- a/web/src/views/Workflow/hooks/useWorkflowGraph.ts
+++ b/web/src/views/Workflow/hooks/useWorkflowGraph.ts
@@ -94,9 +94,7 @@ export const useWorkflowGraph = ({
const { group_names, group } = config
nodeLibraryConfig.config[key].defaultValue = group
? Object.entries(group_names as Record).map(([key, value]) => ({ key, value }))
- : [{ key: 'Group1', value: group_names }]
-
- console.log('group_names', nodeLibraryConfig.config)
+ : group_names
} else if (nodeLibraryConfig.config && nodeLibraryConfig.config[key] && config[key]) {
nodeLibraryConfig.config[key].defaultValue = config[key]
}
@@ -832,7 +830,7 @@ export const useWorkflowGraph = ({
// 创建干净的节点数据,只保留必要的字段
const cleanNodeData = {
- id: `${dragData.type}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
+ id: `${dragData.type.replace(/-/g, '_')}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
name: t(`workflow.${dragData.type}`),
...nodeLibraryConfig
};
@@ -842,6 +840,7 @@ export const useWorkflowGraph = ({
...graphNodeLibrary[dragData.type],
x: point.x - 150,
y: point.y - 100,
+ id: cleanNodeData.id,
data: { ...cleanNodeData, isGroup: true },
});
} else if (dragData.type === 'if-else') {
@@ -850,6 +849,7 @@ export const useWorkflowGraph = ({
...graphNodeLibrary[dragData.type],
x: point.x - 100,
y: point.y - 60,
+ id: cleanNodeData.id,
data: { ...cleanNodeData },
});
} else {
@@ -858,6 +858,7 @@ export const useWorkflowGraph = ({
...(graphNodeLibrary[dragData.type] || graphNodeLibrary.default),
x: point.x - 60,
y: point.y - 20,
+ id: cleanNodeData.id,
data: { ...cleanNodeData },
});
}
@@ -881,7 +882,15 @@ export const useWorkflowGraph = ({
if (data.config) {
Object.keys(data.config).forEach(key => {
- if (data.config[key] && 'defaultValue' in data.config[key] && key !== 'knowledge_retrieval') {
+ if (data.config[key] && 'defaultValue' in data.config[key] && key === 'group_names') {
+ let group_names = data.config.group.defaultValue ? {} : data.config[key].defaultValue
+ if (data.config.group.defaultValue) {
+ data.config[key].defaultValue.map((vo: any) => {
+ group_names[vo.key] = vo.value
+ })
+ }
+ itemConfig[key] = group_names
+ } else if (data.config[key] && 'defaultValue' in data.config[key] && key !== 'knowledge_retrieval') {
itemConfig[key] = data.config[key].defaultValue
} else if (key === 'knowledge_retrieval' && data.config[key] && 'defaultValue' in data.config[key]) {
const { knowledge_bases } = data.config[key].defaultValue
@@ -910,7 +919,7 @@ export const useWorkflowGraph = ({
const sourceCell = graphRef.current?.getCellById(edge.getSourceCellId());
const targetCell = graphRef.current?.getCellById(edge.getTargetCellId());
const sourcePortId = edge.getSourcePortId();
-
+
// 过滤无效连线:源节点或目标节点不存在,或者是add-node类型
if (!sourceCell?.getData()?.id || !targetCell?.getData()?.id ||
sourceCell?.getData()?.type === 'add-node' || targetCell?.getData()?.type === 'add-node') {