diff --git a/web/src/views/Workflow/components/Properties/Knowledge/Knowledge.tsx b/web/src/views/Workflow/components/Properties/Knowledge/Knowledge.tsx index 384de5ec..aeafb67c 100644 --- a/web/src/views/Workflow/components/Properties/Knowledge/Knowledge.tsx +++ b/web/src/views/Workflow/components/Properties/Knowledge/Knowledge.tsx @@ -16,6 +16,7 @@ import KnowledgeListModal from './KnowledgeListModal' import KnowledgeConfigModal from './KnowledgeConfigModal' import KnowledgeGlobalConfigModal from './KnowledgeGlobalConfigModal' import Tag from '@/components/Tag' +import { getKnowledgeBaseList } from '@/api/knowledgeBase' const Knowledge: FC<{value?: KnowledgeConfig; onChange?: (config: KnowledgeConfig) => void}> = ({value = {knowledge_bases: []}, onChange}) => { const { t } = useTranslation() @@ -29,7 +30,26 @@ const Knowledge: FC<{value?: KnowledgeConfig; onChange?: (config: KnowledgeConfi if (value && JSON.stringify(value) !== JSON.stringify(editConfig)) { setEditConfig({ ...(value || {}) }) const knowledge_bases = [...(value.knowledge_bases || [])] - setKnowledgeList(knowledge_bases) + + // 检查是否有knowledge_bases缺少name字段 + const basesWithoutName = knowledge_bases.filter(base => !base.name) + if (basesWithoutName.length > 0) { + // 调用接口获取完整的知识库信息 + getKnowledgeBaseList().then(res => { + const fullBases = knowledge_bases.map(base => { + if (!base.name) { + const fullBase = res.items.find((item: any) => item.id === base.kb_id) + return fullBase ? { ...base, ...fullBase } : base + } + return base + }) + setKnowledgeList(fullBases) + }).catch(() => { + setKnowledgeList(knowledge_bases) + }) + } else { + setKnowledgeList(knowledge_bases) + } } }, [value]) diff --git a/web/src/views/Workflow/components/Properties/index.tsx b/web/src/views/Workflow/components/Properties/index.tsx index 11e3cf1e..be4405db 100644 --- a/web/src/views/Workflow/components/Properties/index.tsx +++ b/web/src/views/Workflow/components/Properties/index.tsx @@ -318,7 +318,7 @@ const Properties: FC = ({ if (selectedNode?.data?.type === 'llm' && key === 'messages' && config.type === 'define') { return ( - + ) } diff --git a/web/src/views/Workflow/constant.ts b/web/src/views/Workflow/constant.ts index 1512b0e5..2aa95d0e 100644 --- a/web/src/views/Workflow/constant.ts +++ b/web/src/views/Workflow/constant.ts @@ -121,7 +121,7 @@ export const nodeLibrary: NodeLibrary[] = [ type: 'define', defaultValue: [ { - role: 'system', + role: 'SYSTEM', content: undefined, readonly: true }, @@ -142,27 +142,27 @@ export const nodeLibrary: NodeLibrary[] = [ } }, // { type: "classification", icon: classificationIcon }, - { type: "parameter-extractor", icon: parameterExtractionIcon, - config: { - model_id: { - type: 'customSelect', - url: getModelListUrl, - params: { type: 'llm,chat' }, // llm/chat - valueKey: 'id', - labelKey: 'name', - }, - text: { - type: 'variableList', - }, - params: { - type: 'paramList', - }, - prompt: { - type: 'messageEditor', - isArray: false, - }, - } - } + // { type: "parameter-extractor", icon: parameterExtractionIcon, + // config: { + // model_id: { + // type: 'customSelect', + // url: getModelListUrl, + // params: { type: 'llm,chat' }, // llm/chat + // valueKey: 'id', + // labelKey: 'name', + // }, + // text: { + // type: 'variableList', + // }, + // params: { + // type: 'paramList', + // }, + // prompt: { + // type: 'messageEditor', + // isArray: false, + // }, + // } + // } ] }, // { @@ -182,115 +182,115 @@ export const nodeLibrary: NodeLibrary[] = [ // { type: "agent_arbitration", icon: agentArbitrationIcon } // ] // }, - { - category: "flowControl", - nodes: [ - { type: "if-else", icon: conditionIcon, - config: { - cases: { - type: 'caseList', - defaultValue: [ - { - logical_operator: 'and', - expressions: [] - } - ] - } - } - }, - // { type: "iteration", icon: iterationIcon }, - // { type: "loop", icon: loopIcon }, - // { type: "parallel", icon: parallelIcon }, - { type: "var-aggregator", icon: aggregatorIcon, - config: { - group: { - type: 'switch', - defaultValue: false - }, - group_names: { - type: 'groupVariableList', - defaultValue: [{ key: 'Group1', value: []}] - } - } - } - ] - }, - { - category: "externalInteraction", - nodes: [ - { type: "http-request", icon: httpRequestIcon, - config: { - method: { - type: 'select', - options: [ - { label: 'GET', value: 'GET' }, - { label: 'POST', value: 'POST' }, - { label: 'HEAD', value: 'HEAD' }, - { label: 'PATCH', value: 'PATCH' }, - { label: 'PUT', value: 'PUT' }, - { label: 'DELETE', value: 'DELETE' }, - ], - defaultValue: 'GET' - }, - url: { - type: 'messageEditor', - isArray: false, - }, - auth: { - type: 'define', - defaultValue: { - auth_type: 'none' - } - }, - headers: { - type: 'define', - defaultValue: {} - }, - params: { - type: 'define', - defaultValue: {} - }, - body: { - type: 'define', - defaultValue: { - 'content_type': 'none' - } - }, - verify_ssl: { - type: 'switch', - defaultValue: false - }, - timeouts: { - type: 'define', - defaultValue: {} - }, - retry: { - type: 'define', - }, - error_handle: { - type: 'define', - defaultValue: { - method: 'default' - } - } - } - }, - // { type: "tools", icon: toolsIcon }, - // { type: "code_execution", icon: codeExecutionIcon }, - { type: "jinja-render", icon: templateRenderingIcon, - config: { - mapping: { - type: 'mappingList', - defaultValue: [] - }, - template: { - type: 'messageEditor', - isArray: false, - }, - } - } - ] - }, + // { + // category: "flowControl", + // nodes: [ + // { type: "if-else", icon: conditionIcon, + // config: { + // cases: { + // type: 'caseList', + // defaultValue: [ + // { + // logical_operator: 'and', + // expressions: [] + // } + // ] + // } + // } + // }, + // // { type: "iteration", icon: iterationIcon }, + // { type: "loop", icon: loopIcon }, + // // { type: "parallel", icon: parallelIcon }, + // { type: "var-aggregator", icon: aggregatorIcon, + // config: { + // group: { + // type: 'switch', + // defaultValue: false + // }, + // group_names: { + // type: 'groupVariableList', + // defaultValue: [{ key: 'Group1', value: []}] + // } + // } + // } + // ] + // }, + // { + // category: "externalInteraction", + // nodes: [ + // { type: "http-request", icon: httpRequestIcon, + // config: { + // method: { + // type: 'select', + // options: [ + // { label: 'GET', value: 'GET' }, + // { label: 'POST', value: 'POST' }, + // { label: 'HEAD', value: 'HEAD' }, + // { label: 'PATCH', value: 'PATCH' }, + // { label: 'PUT', value: 'PUT' }, + // { label: 'DELETE', value: 'DELETE' }, + // ], + // defaultValue: 'GET' + // }, + // url: { + // type: 'messageEditor', + // isArray: false, + // }, + // auth: { + // type: 'define', + // defaultValue: { + // auth_type: 'none' + // } + // }, + // headers: { + // type: 'define', + // defaultValue: {} + // }, + // params: { + // type: 'define', + // defaultValue: {} + // }, + // body: { + // type: 'define', + // defaultValue: { + // 'content_type': 'none' + // } + // }, + // verify_ssl: { + // type: 'switch', + // defaultValue: false + // }, + // timeouts: { + // type: 'define', + // defaultValue: {} + // }, + // retry: { + // type: 'define', + // }, + // error_handle: { + // type: 'define', + // defaultValue: { + // method: 'default' + // } + // } + // } + // }, + // // { type: "tools", icon: toolsIcon }, + // // { type: "code_execution", icon: codeExecutionIcon }, + // { type: "jinja-render", icon: templateRenderingIcon, + // config: { + // mapping: { + // type: 'mappingList', + // defaultValue: [] + // }, + // template: { + // type: 'messageEditor', + // isArray: false, + // }, + // } + // } + // ] + // }, // { // category: "safetyAndCompliance", // nodes: [ @@ -311,8 +311,8 @@ export const nodeLibrary: NodeLibrary[] = [ export const nodeRegisterLibrary: ReactShapeConfig[] = [ { shape: 'loop-node', - width: 200, - height: 200, + width: 240, + height: 80, component: LoopNode, }, { @@ -335,8 +335,8 @@ export const nodeRegisterLibrary: ReactShapeConfig[] = [ }, { shape: 'group-start-node', - width: 120, - height: 40, + width: 44, + height: 44, component: GroupStartNode, }, { @@ -388,7 +388,7 @@ export const graphNodeLibrary: Record = { }, loop: { width: 240, - height: 200, + height: 120, shape: 'loop-node', ports: { groups: defaultPortGroups, diff --git a/web/src/views/Workflow/hooks/useWorkflowGraph.ts b/web/src/views/Workflow/hooks/useWorkflowGraph.ts index 27c168f1..c4482497 100644 --- a/web/src/views/Workflow/hooks/useWorkflowGraph.ts +++ b/web/src/views/Workflow/hooks/useWorkflowGraph.ts @@ -762,9 +762,11 @@ export const useWorkflowGraph = ({ 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 itemConfig = { ...itemConfig, - ...data.config[key].defaultValue + ...data.config[key].defaultValue, + knowledge_bases: knowledge_bases.map((vo: any) => ({ kb_id: vo.id, ...vo.config })) } } })