From c5871c107892b4925f895c103ff9bcad6acc07ed Mon Sep 17 00:00:00 2001 From: Magicbook1108 Date: Thu, 9 Apr 2026 10:55:22 +0800 Subject: [PATCH] Fix: dsl import/export (#13992) ### What problem does this PR solve? Fix: dsl import/export ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) ## Summary by CodeRabbit * **New Features** * Enhanced JSON import functionality for agents to automatically populate components from imported graph structures. --------- Co-authored-by: Zhichang Yu Co-authored-by: Claude Opus 4.6 --- .../test_web_api/test_chunk_feedback/__init__.py | 5 ++++- web/src/pages/agents/use-import-json.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/testcases/test_web_api/test_chunk_feedback/__init__.py b/test/testcases/test_web_api/test_chunk_feedback/__init__.py index 177b91dd0..1a080087b 100644 --- a/test/testcases/test_web_api/test_chunk_feedback/__init__.py +++ b/test/testcases/test_web_api/test_chunk_feedback/__init__.py @@ -12,4 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# + +from rag.flow.chunker.token_chunker import TokenChunker, TokenChunkerParam + +__all__ = ["TokenChunker", "TokenChunkerParam"] diff --git a/web/src/pages/agents/use-import-json.ts b/web/src/pages/agents/use-import-json.ts index 091d20598..6cda70873 100644 --- a/web/src/pages/agents/use-import-json.ts +++ b/web/src/pages/agents/use-import-json.ts @@ -8,6 +8,7 @@ import { Node } from '@xyflow/react'; import isEmpty from 'lodash/isEmpty'; import { useCallback } from 'react'; import { useTranslation } from 'react-i18next'; +import { buildDslComponentsByGraph } from '../agent/utils'; import { DataflowEmptyDsl } from './hooks/use-create-agent'; import { FormSchemaType } from './upload-agent-dialog/upload-agent-form'; @@ -65,6 +66,14 @@ export const useHandleImportJsonFile = () => { dsl.variables = graphOrDsl.variables; } + if (Array.isArray(graph?.nodes) && Array.isArray(graph?.edges)) { + dsl.components = buildDslComponentsByGraph( + graph.nodes as any, + graph.edges as any, + graphOrDsl.components ?? dsl.components, + ); + } + setAgent({ title: name, dsl,