feat: 完成工作流多文件文档解析闭环
- 支持文档解析节点批量解析并收口为 documents 轻量输出 - 收口引用树、节点输出展示与旧工作流固定输出兼容 - 修复共享按钮点击事件,恢复多个节点加号交互
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import type { Parameter } from '#types';
|
||||
|
||||
/**
|
||||
* 解析开始节点参数在引用选择器中的展示名。
|
||||
*
|
||||
* 系统主问题字段始终保持“用户问题”口径;普通自定义字段优先展示参数名,
|
||||
* 避免文件类型字段退化为默认“文件字段”标签。
|
||||
*/
|
||||
export const getStartNodeParameterLabel = (parameter: Parameter) => {
|
||||
const name = String(parameter?.name || '').trim();
|
||||
if (name === 'user_input') {
|
||||
return (
|
||||
String(parameter?.formLabel || parameter?.displayName || '用户问题').trim()
|
||||
|| '用户问题'
|
||||
);
|
||||
}
|
||||
return (
|
||||
name
|
||||
|| String(parameter?.formLabel || parameter?.displayName || '参数').trim()
|
||||
|| '参数'
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
import { type Edge, type Node, useNodesData, useStore } from '@xyflow/svelte';
|
||||
import type { Parameter } from '#types';
|
||||
import { getCurrentNodeId, getOptions } from '#components/utils/NodeUtils';
|
||||
import { getStartNodeParameterLabel } from '#components/utils/startNodeParameterLabel';
|
||||
import { nodeIcons } from '../../consts';
|
||||
|
||||
const fillRefNodeIds = (
|
||||
@@ -21,24 +22,39 @@ const getChildren = (
|
||||
parentId: string,
|
||||
nodeIsChildren: boolean,
|
||||
nodeType: string,
|
||||
parentPathLabel = '',
|
||||
parentIsCollection = false,
|
||||
) => {
|
||||
if (!params || params.length === 0) return [];
|
||||
return params.map((param: any) => {
|
||||
const isCollection = param.dataType === 'Array' && param.children && param.children.length > 0;
|
||||
const childBaseLabel = param.formLabel || param.displayName || param.name;
|
||||
const normalizedChildLabel = String(childBaseLabel || '').trim();
|
||||
const pathLabel = !parentPathLabel
|
||||
? normalizedChildLabel
|
||||
: parentIsCollection
|
||||
? `${parentPathLabel}.[].${normalizedChildLabel}`
|
||||
: `${parentPathLabel}.${normalizedChildLabel}`;
|
||||
const dataType = nodeIsChildren
|
||||
? `Array<${param.dataType || 'String'}>`
|
||||
: param.dataType || 'String';
|
||||
const label = param.formLabel || param.displayName || param.name;
|
||||
return {
|
||||
label,
|
||||
label: pathLabel,
|
||||
dataType: dataType,
|
||||
value: parentId + '.' + param.name,
|
||||
selectable: true,
|
||||
nodeType: nodeType,
|
||||
displayLabel: pathLabel,
|
||||
pathLabel,
|
||||
itemTypeLabel: parentIsCollection ? '数组项字段' : undefined,
|
||||
isCollection,
|
||||
children: getChildren(
|
||||
param.children,
|
||||
parentId + '.' + param.name,
|
||||
nodeIsChildren,
|
||||
nodeType,
|
||||
pathLabel,
|
||||
isCollection,
|
||||
),
|
||||
};
|
||||
});
|
||||
@@ -72,8 +88,7 @@ const nodeToOptions = (
|
||||
const dataType = nodeIsChildren
|
||||
? `Array<${parameter.dataType || 'String'}>`
|
||||
: parameter.dataType || 'String';
|
||||
const label =
|
||||
parameter.formLabel || parameter.displayName || parameter.name;
|
||||
const label = getStartNodeParameterLabel(parameter);
|
||||
children.push({
|
||||
label,
|
||||
dataType: dataType,
|
||||
|
||||
Reference in New Issue
Block a user