Skip to content

Commit 7566de2

Browse files
RonnyChan96wuayee
authored andcommitted
[app-builder] 并行节点特性添加 (ModelEngine-Group#180)
1 parent 5af964f commit 7566de2

File tree

12 files changed

+55
-22
lines changed

12 files changed

+55
-22
lines changed

app-builder/jane/plugins/aipp-plugin/src/main/resources/application-prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ tool:
7373
TEXTTOIMAGENODESTATE: textToImageNodeState
7474
FILEEXTRACTNODESTATE: fileExtractionNodeState
7575
LOOPNODESTATE: loopNodeState
76+
PARALLELNODESTATE: parallelNodeState
7677
export-meta:
7778
version: 1.0.1
7879
sensitive:

app-builder/jane/plugins/aipp-plugin/src/main/resources/component/basic_node_en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
"name": "Loop",
7070
"uniqueName": ""
7171
},
72+
{
73+
"type": "parallelNodeState",
74+
"name": "Parallel",
75+
"uniqueName": ""
76+
},
7277
{
7378
"type": "manualCheckNodeState",
7479
"name": "Manual Form",

app-builder/jane/plugins/aipp-plugin/src/main/resources/component/basic_node_zh.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
"name": "循环",
7070
"uniqueName": ""
7171
},
72+
{
73+
"type": "parallelNodeState",
74+
"name": "并行",
75+
"uniqueName": ""
76+
},
7277
{
7378
"type": "manualCheckNodeState",
7479
"name": "人工表单",

app-builder/plugins/aipp-parallel-tool/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
<configuration>
136136
<target>
137137
<copy file="${project.build.directory}/${project.build.finalName}.jar"
138-
todir="../../../framework/fit/java/target/plugins"/>
138+
todir="../../../build/plugins"/>
139139
</target>
140140
</configuration>
141141
<goals>

app-builder/plugins/aipp-parallel-tool/src/main/java/modelengine/fit/jade/aipp/tool/parallel/domain/BatchRequest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,10 @@ private boolean postUndoTask() {
123123
task.getIndex());
124124

125125
this.doingToolCallTasks.put(task.getIndex(), task);
126-
Map<String, Object> toolArgs = task.getToolCall()
127-
.getArgs()
128-
.stream()
129-
.collect(Collectors.toMap(Argument::getName, Argument::getValue));
126+
String jsonArgs = JSONObject.toJSONString(task.getToolCall().getArgs(),
127+
SerializerFeature.WriteMapNullValue);
130128
this.complete(task,
131-
JSONArray.parse(this.syncToolCall.call(task.getToolCall().getUniqueName(),
132-
JSONObject.toJSONString(toolArgs, SerializerFeature.WriteMapNullValue))));
129+
JSONArray.parse(this.syncToolCall.call(task.getToolCall().getUniqueName(), jsonArgs)));
133130
} catch (Throwable ex) {
134131
this.setException(task, ex);
135132
} finally {

app-builder/plugins/aipp-parallel-tool/src/main/java/modelengine/fit/jade/aipp/tool/parallel/entities/ToolCall.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import lombok.Data;
1212
import lombok.NoArgsConstructor;
1313

14-
import java.util.List;
14+
import java.util.Map;
1515

1616
/**
1717
* 并行工具调用信息。
@@ -25,6 +25,6 @@
2525
@AllArgsConstructor
2626
public class ToolCall {
2727
private String uniqueName;
28-
private List<Argument> args;
28+
private Map<String, Object> args;
2929
private String outputName;
3030
}

app-builder/plugins/aipp-parallel-tool/src/main/java/modelengine/fit/jade/aipp/tool/parallel/service/impl/ParallelToolServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ private void validateToolCall(ToolCall toolCall) {
9494
Validation.isTrue(StringUtils.isNotEmpty(toolCall.getUniqueName()),
9595
"The tool unique name should not be empty.");
9696
Validation.notNull(toolCall.getArgs(), "The tool args should not be null.");
97-
toolCall.getArgs().forEach(arg -> {
97+
toolCall.getArgs().entrySet().forEach(arg -> {
9898
Validation.notNull(arg,
9999
StringUtils.format("The tool arg should not be null. [toolUniqueName={0}]",
100100
toolCall.getUniqueName()));
101-
Validation.isTrue(StringUtils.isNotEmpty(arg.getName()),
101+
Validation.isTrue(StringUtils.isNotEmpty(arg.getKey()),
102102
StringUtils.format("The tool arg name should not be empty. [toolUniqueName={0}]",
103103
toolCall.getUniqueName()));
104104
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
INSERT INTO "public"."store_plugin" ("plugin_id", "plugin_name", "extension", "deploy_status", "is_builtin", "source", "icon") VALUES ('d44a239ed854ef94af0f032a526907e20ba8a56ebb4f851cc6956c0172a144e7', '并行', '{"uniqueness.groupId":"modelengine.fit.jade.plugin","pluginFullName":"aipp-parallel-tool-1.0.0-SNAPSHOT_1745841582889.jar","checksum":"42266c0ada1415feb0b689f288b4063b9406506ff7da16eca0332b91a01df20e","name":"并行","description":"并行执行工具","uniqueness.artifactId":"aipp-parallel-tool","type":"java"}', 'DEPLOYED', 't', '', NULL) ON CONFLICT ("plugin_id") DO NOTHING;
2+
3+
INSERT INTO "public"."store_plugin_tool" ("tool_name", "plugin_id", "tool_unique_name") VALUES ('parallelToolDefault', 'd44a239ed854ef94af0f032a526907e20ba8a56ebb4f851cc6956c0172a144e7', '1d0c8164-1aea-4264-879f-2c7898d13fb9') ON CONFLICT ("plugin_id", "tool_unique_name") DO NOTHING;
4+
5+
INSERT INTO "public"."store_definition" ("name", "schema", "definition_group_name") VALUES ('parallelTool', '{"name":"parallelTool","description":"用于并行执行工具","parameters":{"type":"object","properties":{"toolCalls":{"defaultValue":"","description":"并行调用的工具列表","name":"toolCalls","type":"array","items":{"type":"object","properties":{"uniqueName":{"type":"string"},"args":{"type":"object"},"outputName":{"type":"string"}}},"examples":"","required":[]},"config":{"defaultValue":"","description":"并行调用的配置","name":"config","type":"object","properties":{"concurrency":{"type":"integer"}},"examples":"","required":[]},"context":{"defaultValue":"","description":"调用时的上下文信息","name":"context","type":"object","examples":"","required":[]}},"required":["toolCalls"]},"order":["toolCalls","config","context"],"parameterExtensions":null,"return":{"type":"object","convertor":""}}', 'ParallelTool') ON CONFLICT ("definition_group_name", "name") DO NOTHING;
6+
7+
INSERT INTO "public"."store_tag" ("tool_unique_name", "name") VALUES ('1d0c8164-1aea-4264-879f-2c7898d13fb9', 'FIT') ON CONFLICT ("tool_unique_name", "name") DO NOTHING;
8+
INSERT INTO "public"."store_tag" ("tool_unique_name", "name") VALUES ('1d0c8164-1aea-4264-879f-2c7898d13fb9', 'PARALLELNODESTATE') ON CONFLICT ("tool_unique_name", "name") DO NOTHING;
9+
INSERT INTO "public"."store_tag" ("tool_unique_name", "name") VALUES ('1d0c8164-1aea-4264-879f-2c7898d13fb9', 'BASIC') ON CONFLICT ("tool_unique_name", "name") DO NOTHING;
10+
11+
12+
INSERT INTO "public"."store_tool" ("name", "schema", "runnables", "extensions", "unique_name", "version", "is_latest", "group_name", "definition_name", "definition_group_name") VALUES ('parallelToolDefault', '{"name":"parallelTool","description":"用于并行执行工具","parameters":{"type":"object","properties":{"toolCalls":{"defaultValue":"","description":"并行调用的工具列表","name":"toolCalls","type":"array","items":{"type":"object","properties":{"uniqueName":{"type":"string"},"args":{"type":"object"},"outputName":{"type":"string"}}},"examples":"","required":[]},"config":{"defaultValue":"","description":"并行调用的配置","name":"config","type":"object","properties":{"concurrency":{"type":"integer"}},"examples":"","required":[]},"context":{"defaultValue":"","description":"调用时的上下文信息","name":"context","type":"object","examples":"","required":[]}},"required":["toolCalls"]},"order":["toolCalls","config","context"],"parameterExtensions":null,"return":{"type":"object","convertor":""}}', '{"FIT":{"genericableId":"modelengine.fit.jade.aipp.tool.parallel","fitableId":"default"}}', '{"tags":["FIT","BASIC","PARALLELNODESTATE"]}', '1d0c8164-1aea-4264-879f-2c7898d13fb9', '1.0.0', 't', 'ParallelToolImpl', 'parallelTool', 'ParallelTool') ON CONFLICT ("unique_name", "version") DO NOTHING;

app-builder/plugins/aipp-parallel-tool/src/test/java/modelengine/fit/jade/aipp/tool/parallel/domain/BatchRequestTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.ArrayList;
2626
import java.util.Arrays;
2727
import java.util.Collections;
28+
import java.util.HashMap;
2829
import java.util.List;
2930
import java.util.Map;
3031

@@ -47,9 +48,9 @@ class BatchRequestTest {
4748

4849
@Test
4950
void shouldCallExecutorByConcurrencyWhenPostGivenToolCall() {
50-
List<ToolCall> toolCalls = Arrays.asList(ToolCall.builder().uniqueName("u1").args(new ArrayList<>()).build(),
51-
ToolCall.builder().uniqueName("u2").args(new ArrayList<>()).build(),
52-
ToolCall.builder().uniqueName("u3").args(new ArrayList<>()).build());
51+
List<ToolCall> toolCalls = Arrays.asList(ToolCall.builder().uniqueName("u1").args(new HashMap<>()).build(),
52+
ToolCall.builder().uniqueName("u2").args(new HashMap<>()).build(),
53+
ToolCall.builder().uniqueName("u3").args(new HashMap<>()).build());
5354
Config config = Config.builder().concurrency(2).build();
5455
Mockito.doNothing().when(this.taskExecutor).post(Mockito.any());
5556

@@ -67,10 +68,10 @@ void shouldCallExecutorByConcurrencyWhenPostGivenToolCall() {
6768
@Test
6869
void shouldGetResultWhenAwaitGivenToolCallSuccessfully() {
6970
List<ToolCall> toolCalls =
70-
Arrays.asList(ToolCall.builder().uniqueName("u1").args(new ArrayList<>()).outputName("1").build(),
71+
Arrays.asList(ToolCall.builder().uniqueName("u1").args(new HashMap<>()).outputName("1").build(),
7172
ToolCall.builder()
7273
.uniqueName("u2")
73-
.args(Collections.singletonList(Argument.builder().name("a").value(1).build()))
74+
.args(MapBuilder.<String, Object>get().put("a", 1).build())
7475
.outputName("2")
7576
.build());
7677
Config config = Config.builder().concurrency(1).build();
@@ -104,8 +105,8 @@ void shouldGetResultWhenAwaitGivenToolCallSuccessfully() {
104105

105106
@Test
106107
void shouldThrowExceptionWhenAwaitGivenToolCallException() {
107-
List<ToolCall> toolCalls = Arrays.asList(ToolCall.builder().uniqueName("u1").args(new ArrayList<>()).build(),
108-
ToolCall.builder().uniqueName("u2").args(new ArrayList<>()).build());
108+
List<ToolCall> toolCalls = Arrays.asList(ToolCall.builder().uniqueName("u1").args(new HashMap<>()).build(),
109+
ToolCall.builder().uniqueName("u2").args(new HashMap<>()).build());
109110
Config config = Config.builder().concurrency(1).build();
110111
Mockito.doAnswer((Answer<Void>) invocation -> {
111112
Runnable runnable = invocation.getArgument(0);
@@ -130,8 +131,8 @@ void shouldThrowExceptionWhenAwaitGivenToolCallException() {
130131

131132
@Test
132133
void shouldNotExecuteRemainToolWhenAwaitGivenInstanceNotRunning() {
133-
List<ToolCall> toolCalls = Arrays.asList(ToolCall.builder().uniqueName("u1").args(new ArrayList<>()).build(),
134-
ToolCall.builder().uniqueName("u2").args(new ArrayList<>()).build());
134+
List<ToolCall> toolCalls = Arrays.asList(ToolCall.builder().uniqueName("u1").args(new HashMap<>()).build(),
135+
ToolCall.builder().uniqueName("u2").args(new HashMap<>()).build());
135136
Config config = Config.builder().concurrency(1).build();
136137
Mockito.doAnswer((Answer<Void>) invocation -> {
137138
Runnable runnable = invocation.getArgument(0);

app-engine/frontend/src/locale/en_US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,5 +951,6 @@
951951
"reorganizeNodes": "Organize nodes",
952952
"zoomOut": "Zoom Out",
953953
"zoomIn": "Zoom In",
954-
"formItemFieldTypeCannotBeEmpty": "Field type is required"
954+
"formItemFieldTypeCannotBeEmpty": "Field type is required",
955+
"addParallelTask": "Add Parallel Tasks"
955956
}

0 commit comments

Comments
 (0)