From b569991a354422a098edf097c5f9cc6fd89dc8fa Mon Sep 17 00:00:00 2001 From: 0007 <0007@qq.com> Date: Wed, 27 Aug 2025 19:58:10 +0800 Subject: [PATCH] Add File --- .../agentsflex/core/test/chain/ChainTest.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 agents-flex-core/src/test/java/com/agentsflex/core/test/chain/ChainTest.java diff --git a/agents-flex-core/src/test/java/com/agentsflex/core/test/chain/ChainTest.java b/agents-flex-core/src/test/java/com/agentsflex/core/test/chain/ChainTest.java new file mode 100644 index 0000000..30ada17 --- /dev/null +++ b/agents-flex-core/src/test/java/com/agentsflex/core/test/chain/ChainTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023-2025, Agents-Flex (fuhai999@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ +package com.agentsflex.core.test.chain; + +import com.agentsflex.core.chain.*; +import com.agentsflex.core.chain.listener.ChainEventListener; +import com.agentsflex.core.chain.listener.ChainSuspendListener; +import com.agentsflex.core.chain.node.LlmNode; +import com.agentsflex.core.chain.node.StartNode; +import com.agentsflex.core.util.Maps; + +import java.util.Collections; +import java.util.List; +import java.util.UUID; + +public class ChainTest { + + public static void main(String[] args) { + + StartNode startNode = new StartNode(); + startNode.setId(UUID.randomUUID().toString()); + + LlmNode endNode = new LlmNode(); + endNode.setId(UUID.randomUUID().toString()); + + Parameter parameter = new Parameter(); + parameter.setName("test"); + parameter.setDataType(DataType.String); + parameter.setRequired(true); + + endNode.addInputParameter(parameter); + + Chain chain = new Chain(); + chain.addNode(startNode); + chain.addNode(endNode); + + ChainEdge edge = new ChainEdge(); + edge.setId(UUID.randomUUID().toString()); + edge.setSource(startNode.getId()); + edge.setTarget(endNode.getId()); + chain.addEdge(edge); + + + chain.addEventListener(new ChainEventListener() { + @Override + public void onEvent(ChainEvent event, Chain chain) { + System.out.println("onEvent: " + event.getClass()); + } + }); + + + chain.addSuspendListener(new ChainSuspendListener() { + + @Override + public void onSuspend(Chain chain) { + System.out.println("------------onSuspend-----------"); + List suspendForParameters = chain.getSuspendForParameters(); + System.out.println("suspendForParameters: " + suspendForParameters); + + chain.resume(Maps.of("test","123")); + } + }); + + + chain.execute(Collections.emptyMap()); + + } +}