feat(web): memory-read、memory-write、iteration、assigner、tool node

This commit is contained in:
zhaoying
2026-01-05 16:18:04 +08:00
parent a66fb9eade
commit 3e71e4d15e
15 changed files with 849 additions and 63 deletions

View File

@@ -156,6 +156,43 @@ export const useWorkflowGraph = ({
nodeConfig.height = newHeight;
}
// 如果是question-classifier节点根据categories动态生成端口
if (type === 'question-classifier' && config.categories && Array.isArray(config.categories)) {
const categoryCount = config.categories.length;
const baseHeight = 88;
const newHeight = baseHeight + (categoryCount - 1) * 30;
const portAttrs = {
circle: {
r: 4, magnet: true, stroke: '#155EEF', strokeWidth: 2, fill: '#155EEF', position: { top: 22 }
},
};
const portItems: PortMetadata[] = [
{ group: 'left' }
];
// 添加分类端口
config.categories.forEach((category: any, index: number) => {
portItems.push({
group: 'right',
id: `CASE${index + 1}`,
args: index === 0 ? { dy: 24 } : undefined,
attrs: { text: { text: category.class_name || `分类${index + 1}`, fontSize: 12, fill: '#5B6167' }}
});
});
nodeConfig.ports = {
groups: {
right: { position: 'right', attrs: portAttrs },
left: { position: 'left', attrs: portAttrs },
},
items: portItems
};
nodeConfig.height = newHeight;
}
return nodeConfig
})
@@ -239,6 +276,14 @@ export const useWorkflowGraph = ({
}
}
// 如果是question-classifier节点且有label根据label匹配对应的端口
if (sourceCell.getData()?.type === 'question-classifier' && label) {
const matchingPort = sourcePorts.find((port: any) => port.id === label);
if (matchingPort) {
sourcePort = label;
}
}
const edgeConfig = {
source: {
cell: sourceCell.id,
@@ -881,6 +926,15 @@ export const useWorkflowGraph = ({
};
}
// 如果是question-classifier节点的右侧端口连线添加label
if (sourceCell?.getData()?.type === 'question-classifier' && sourcePortId?.startsWith('CASE')) {
return {
source: sourceCell.getData().id,
target: targetCell?.getData().id,
label: sourcePortId,
};
}
return {
source: sourceCell?.getData().id,
target: targetCell?.getData().id,