|
|
@@ -11,6 +11,7 @@ import com.agentsflex.core.chain.listener.ChainEventListener;
|
|
|
import com.agentsflex.core.chain.listener.ChainOutputListener;
|
|
|
import com.agentsflex.llm.openai.OpenAILlm;
|
|
|
import com.ruoyi.interfaces.tinyflow.parser.PrintNodeParser;
|
|
|
+import com.ruoyi.interfaces.tinyflow.parser.ServiceNodeParser;
|
|
|
import dev.tinyflow.core.Tinyflow;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
@@ -31,7 +32,7 @@ public class TinyflowTest {
|
|
|
" \"expand\": true,\n" +
|
|
|
" \"parameters\": [\n" +
|
|
|
" {\n" +
|
|
|
- " \"name\": \"inputParam1\",\n" +
|
|
|
+ " \"name\": \"year\",\n" +
|
|
|
" \"dataType\": \"String\",\n" +
|
|
|
" \"refType\": \"input\",\n" +
|
|
|
" \"required\": true,\n" +
|
|
|
@@ -60,25 +61,71 @@ public class TinyflowTest {
|
|
|
" {\n" +
|
|
|
" \"id\": \"2\",\n" +
|
|
|
" \"data\": {\n" +
|
|
|
- " \"title\": \"打印节点\",\n" +
|
|
|
+ " \"title\": \"服务节点\",\n" +
|
|
|
" \"parameters\": [\n" +
|
|
|
" {\n" +
|
|
|
- " \"name\": \"message\",\n" +
|
|
|
- " \"value\": \"Hello value\",\n" +
|
|
|
+ " \"name\": \"year\",\n" +
|
|
|
" \"dataType\": \"String\",\n" +
|
|
|
- " \"defaultValue\": \"Hello defaultValue\",\n" +
|
|
|
- " \"refType\": \"fixed\"\n" +
|
|
|
- " },\n" +
|
|
|
- " {\n" +
|
|
|
- " \"name\": \"input1\",\n" +
|
|
|
- " \"dataType\": \"String\",\n" +
|
|
|
- " \"defaultValue\": \"Hello defaultValue\",\n" +
|
|
|
- " \"ref\": \"1.inputParam1\",\n" +
|
|
|
+ " \"ref\": \"1.year\",\n" +
|
|
|
" \"refType\": \"ref\"\n" +
|
|
|
" }\n" +
|
|
|
- " ]\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"service\": {\n" +
|
|
|
+ " \"srvId\": \"634ae1e0ee78e00bd609b85514961373\",\n" +
|
|
|
+ " \"mdid\": \"e4dc50dd-c4a9-4639-b43e-62e48314a7e0\",\n" +
|
|
|
+ " \"cateCode\": \"S\",\n" +
|
|
|
+ " \"name\": \"获取台风信息列表\",\n" +
|
|
|
+ " \"intro\": \"获取有台风的编号及名称\",\n" +
|
|
|
+ " \"serviceSource\": null,\n" +
|
|
|
+ " \"serviceDept\": null,\n" +
|
|
|
+ " \"manageName\": null,\n" +
|
|
|
+ " \"developUnit\": null,\n" +
|
|
|
+ " \"developContacter\": null,\n" +
|
|
|
+ " \"maintainUnit\": null,\n" +
|
|
|
+ " \"maintainContacer\": null,\n" +
|
|
|
+ " \"upCycl\": null,\n" +
|
|
|
+ " \"openCndtn\": null,\n" +
|
|
|
+ " \"adName\": null,\n" +
|
|
|
+ " \"dataField\": null,\n" +
|
|
|
+ " \"dataRange\": null,\n" +
|
|
|
+ " \"userId\": null,\n" +
|
|
|
+ " \"status\": null,\n" +
|
|
|
+ " \"note\": null,\n" +
|
|
|
+ " \"type\": \"HTTP\",\n" +
|
|
|
+ " \"url\": \"http://49.4.2.185:2111/RiverStrongAPI2.0/StormSurgeForecast/Typhoon/GetInfos\",\n" +
|
|
|
+ " \"rqtype\": \"POST\",\n" +
|
|
|
+ " \"rptype\": \"1\",\n" +
|
|
|
+ " \"rpcontent\": \"{\\n \\\"data\\\": [\\n {\\n \\\"typhoonId\\\": \\\"202317\\\",\\n \\\"typhoonName\\\": \\\"杰拉华\\\",\\n \\\"test\\\": \\\"1123\\\"\\n },\\n {\\n \\\"typhoonId\\\": \\\"202316\\\",\\n \\\"typhoonName\\\": \\\"三巴\\\",\\n \\\"test\\\": \\\"1123\\\"\\n \\n }\\n ],\\n \\\"succeeded\\\": true,\\n \\\"statusCode\\\": 200,\\n \\\"remark\\\": \\\"获取该年台风信息成功\\\"\\n}\",\n" +
|
|
|
+ " \"proxyAddress\": null,\n" +
|
|
|
+ " \"proxyPath\": null,\n" +
|
|
|
+ " \"example\": \"\",\n" +
|
|
|
+ " \"cnt\": null,\n" +
|
|
|
+ " \"viewNum\": 0,\n" +
|
|
|
+ " \"applyNum\": null,\n" +
|
|
|
+ " \"dataNum\": null,\n" +
|
|
|
+ " \"tm\": null,\n" +
|
|
|
+ " \"uptm\": null,\n" +
|
|
|
+ " \"rlstm\": null,\n" +
|
|
|
+ " \"releaseTime\": null,\n" +
|
|
|
+ " \"attentionId\": null,\n" +
|
|
|
+ " \"params\": [\n" +
|
|
|
+ " {\n" +
|
|
|
+ " \"srvId\": \"634ae1e0ee78e00bd609b85514961373\",\n" +
|
|
|
+ " \"paramCode\": \"year\",\n" +
|
|
|
+ " \"paramName\": \"年份\",\n" +
|
|
|
+ " \"paramType\": \"int\",\n" +
|
|
|
+ " \"paramValue\": \"2023\",\n" +
|
|
|
+ " \"paramFormat\": null,\n" +
|
|
|
+ " \"paramNote\": \"\",\n" +
|
|
|
+ " \"sort\": 0,\n" +
|
|
|
+ " \"paramObject\": 2023\n" +
|
|
|
+ " }\n" +
|
|
|
+ " ],\n" +
|
|
|
+ " \"sort\": null,\n" +
|
|
|
+ " \"audit\": null\n" +
|
|
|
+ " }\n" +
|
|
|
" },\n" +
|
|
|
- " \"type\": \"printNode\",\n" +
|
|
|
+ " \"type\": \"serviceNode\",\n" +
|
|
|
" \"position\": {\n" +
|
|
|
" \"x\": 600,\n" +
|
|
|
" \"y\": 50\n" +
|
|
|
@@ -99,8 +146,8 @@ public class TinyflowTest {
|
|
|
" \"outputDefs\": [\n" +
|
|
|
" {\n" +
|
|
|
" \"name\": \"data\",\n" +
|
|
|
- " \"dataType\": \"String\",\n" +
|
|
|
- " \"ref\": \"2.msg\",\n" +
|
|
|
+ " \"dataType\": \"Object\",\n" +
|
|
|
+ " \"ref\": \"2.result\",\n" +
|
|
|
" \"refType\": \"ref\"\n" +
|
|
|
" }\n" +
|
|
|
" ]\n" +
|
|
|
@@ -150,10 +197,11 @@ public class TinyflowTest {
|
|
|
System.out.println(data1);
|
|
|
Tinyflow tinyflow = new Tinyflow(data1);
|
|
|
tinyflow.getChainParser().addNodeParser("printNode",new PrintNodeParser());
|
|
|
+ tinyflow.getChainParser().addNodeParser("serviceNode",new ServiceNodeParser());
|
|
|
// tinyflow.setLlmProvider(id -> OpenAILlm.of(""));
|
|
|
|
|
|
Map<String, Object> variables = new HashMap<>();
|
|
|
- variables.put("inputParam1", "开始节点引入1");
|
|
|
+ variables.put("year", "2024");
|
|
|
variables.put("inputParam2", 2);
|
|
|
|
|
|
Chain chain = tinyflow.toChain();
|