Skip to content

Commit 34b7c21

Browse files
authored
[app-builder] add reply node (#471)
* [app-builder] add reply node * [app-builder] modify according to reviews * [frontend] replace the icon of reply node
1 parent 5875ee7 commit 34b7c21

File tree

21 files changed

+196
-38
lines changed

21 files changed

+196
-38
lines changed

app-builder/plugins/aipp-plugin/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@
288288
<groupId>modelengine.fit.jade.service</groupId>
289289
<artifactId>knowledge-service</artifactId>
290290
</dependency>
291+
<dependency>
292+
<groupId>modelengine.jade.service</groupId>
293+
<artifactId>aipp-template-render-service</artifactId>
294+
</dependency>
291295
</dependencies>
292296

293297
<build>

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/domains/task/TaskDecorator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private Object invokeMethod(Method method, Object[] args, Object current)
111111
else {
112112
msg = localeService.localize(UI_WORD_KEY);
113113
}
114-
this.aippLogService.insertLogWithInterception(AippInstLogType.ERROR.name(),
114+
this.aippLogService.insertLog(AippInstLogType.ERROR.name(),
115115
AippLogData.builder().msg(msg).build(), ctx.getBusinessData());
116116
return null;
117117
}

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/domains/taskinstance/TaskInstanceDecorator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private Object wrapException(AppTaskInstanceService instanceService, AippLogServ
142142
.setStatus(MetaInstStatusEnum.ERROR.name())
143143
.build(), ctx.getOperationContext());
144144
// 更新日志类型为HIDDEN_FORM
145-
logService.insertLogWithInterception(AippInstLogType.ERROR.name(), AippLogData.builder().msg(e.getMessage()).build(),
145+
logService.insertLog(AippInstLogType.ERROR.name(), AippLogData.builder().msg(e.getMessage()).build(),
146146
ctx.getBusinessData());
147147
}
148148
return null;

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/fitable/AippFlowEndCallback.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private String saveFormToLog(String appId, Map<String, Object> businessData, Str
186186
logData.setFormAppearance(JsonUtils.toJsonString(formDataMap.get(AippConst.FORM_APPEARANCE_KEY)));
187187
logData.setFormData(JsonUtils.toJsonString(formDataMap.get(AippConst.FORM_DATA_KEY)));
188188
// 子应用/工作流的结束节点表单不需要在历史记录展示
189-
return this.aippLogService.insertLogWithInterception((this.isExistParent(businessData)
189+
return this.aippLogService.insertLog((this.isExistParent(businessData)
190190
? AippInstLogType.HIDDEN_FORM
191191
: AippInstLogType.FORM).name(), logData, businessData);
192192
}
@@ -211,7 +211,7 @@ private void logFinalOutput(Map<String, Object> businessData, String aippInstId)
211211
if (!checkEnableLog(businessData)) {
212212
logType = AippInstLogType.HIDDEN_MSG;
213213
}
214-
this.aippLogService.insertLogWithInterception(logType.name(), AippLogData.builder().msg(logMsg).build(), businessData);
214+
this.aippLogService.insertLog(logType.name(), AippLogData.builder().msg(logMsg).build(), businessData);
215215
this.beanContainer.all(AppFlowFinishObserver.class)
216216
.stream()
217217
.<AppFlowFinishObserver>map(BeanFactory::get)

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/fitable/AippFlowSmartFormHandle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private String insertFormLog(List<AppBuilderFormProperty> formProperties, String
179179
Object appearance = formDataMap.get(AippConst.FORM_APPEARANCE_KEY);
180180
logData.setFormAppearance(ObjectUtils.cast(JsonUtils.toJsonString(appearance)));
181181
logData.setFormData(ObjectUtils.cast(JsonUtils.toJsonString(formDataMap.get(AippConst.FORM_DATA_KEY))));
182-
return this.aippLogService.insertLogWithInterception(AippInstLogType.FORM.name(), logData, businessData);
182+
return this.aippLogService.insertLog(AippInstLogType.FORM.name(), logData, businessData);
183183
}
184184

185185
private void updateInstance(String sheetId, String nodeId, Map<String, Object> businessData) {

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/fitable/LlmComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ private void addAnswer(AippLlmMeta llmMeta, String answer, Map<String, Object> p
291291
llmOutput.put("output", output);
292292
Optional<ResponsibilityResult> formatOutput = this.formatterChain.handle(llmOutput);
293293
String logMsg = formatOutput.map(ResponsibilityResult::text).orElse(answer);
294-
this.aippLogService.insertLogWithInterception(AippInstLogType.META_MSG.name(),
294+
this.aippLogService.insertLog(AippInstLogType.META_MSG.name(),
295295
AippLogData.builder().msg(logMsg).build(),
296296
businessData);
297297
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.jober.aipp.fitable;
8+
9+
import modelengine.fit.jade.aipp.template.render.TemplateService;
10+
import modelengine.fit.jober.aipp.entity.AippLogData;
11+
import modelengine.fit.jober.aipp.enums.AippInstLogType;
12+
import modelengine.fit.jober.aipp.service.AippLogService;
13+
import modelengine.fit.jober.aipp.util.DataUtils;
14+
import modelengine.fit.waterflow.spi.FlowableService;
15+
import modelengine.fitframework.annotation.Component;
16+
import modelengine.fitframework.annotation.Fitable;
17+
import modelengine.fitframework.util.ObjectUtils;
18+
19+
import java.util.List;
20+
import java.util.Map;
21+
22+
/**
23+
* 直接回复节点实现
24+
*
25+
* @author 孙怡菲
26+
* @since 2025-09-11
27+
*/
28+
@Component
29+
public class ReplyNode implements FlowableService {
30+
private final static String TEMPLATE_KEY = "template";
31+
32+
private final static String VARIABLES_KEY = "variables";
33+
34+
private final AippLogService aippLogService;
35+
36+
private final TemplateService templateService;
37+
38+
public ReplyNode(AippLogService aippLogService, TemplateService templateService) {
39+
this.aippLogService = aippLogService;
40+
this.templateService = templateService;
41+
}
42+
43+
@Override
44+
@Fitable("modelengine.fit.jober.aipp.fitable.ReplyNodeComponent")
45+
public List<Map<String, Object>> handleTask(List<Map<String, Object>> flowData) {
46+
Map<String, Object> businessData = DataUtils.getBusiness(flowData);
47+
String template = ObjectUtils.cast(businessData.get(TEMPLATE_KEY));
48+
Map<String, Object> args = ObjectUtils.cast(businessData.get(VARIABLES_KEY));
49+
String msg = this.templateService.renderTemplate(template, args);
50+
this.sendMsg(msg, businessData);
51+
return flowData;
52+
}
53+
54+
private void sendMsg(String msg, Map<String, Object> businessData) {
55+
this.aippLogService.insertLog(AippInstLogType.MSG.name(),
56+
AippLogData.builder().msg(msg).build(),
57+
businessData);
58+
}
59+
}

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/service/AippLogService.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public interface AippLogService {
9393
* @param businessData 业务数据
9494
* @return 返回插入的日志id
9595
*/
96-
String insertLogWithInterception(String logType, AippLogData logData, Map<String, Object> businessData);
96+
String insertLog(String logType, AippLogData logData, Map<String, Object> businessData);
9797

9898
/**
9999
* 插入ERROR类型的历史记录
@@ -185,13 +185,4 @@ List<AippInstLogDataDto> queryAippRecentInstLogAfterSplice(String aippId, String
185185
* @param logIds 表示指定的日志 id 列表的 {@link List}{@code <}{@link Long}{@code >}。
186186
*/
187187
void deleteLogs(List<Long> logIds);
188-
189-
/**
190-
* 插入一条日志记录,但不触发发送逻辑。
191-
*
192-
* @param logType 表示日志类型的 {@link String}。
193-
* @param logData 表示日志主体数据的 {@link AippLogData} 实例。
194-
* @param businessData 表示业务数据的 {@link Map}{@code <}{@link String}{@code , }{@link Object}{@code >}。
195-
*/
196-
void insertLog(String logType, AippLogData logData, Map<String, Object> businessData);
197188
}

app-builder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/service/impl/AippLogServiceImpl.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public void deleteAippPreviewLog(String previewAippId, OperationContext context)
362362
* @return 日志id
363363
*/
364364
@Override
365-
public String insertLogWithInterception(String logType, AippLogData logData, Map<String, Object> businessData) {
365+
public String insertLog(String logType, AippLogData logData, Map<String, Object> businessData) {
366366
AippLogCreateDto logCreateDto = this.buildAippLogCreateDto(logType, logData, businessData);
367367
if (logCreateDto == null) {
368368
return null;
@@ -416,7 +416,7 @@ private Boolean isEnableLog(Map<String, Object> businessData) {
416416
@Override
417417
public void insertErrorLog(String msg, List<Map<String, Object>> flowData) {
418418
AippLogData logData = AippLogData.builder().msg(msg).build();
419-
insertLogWithInterception(AippInstLogType.ERROR.name(), logData, DataUtils.getBusiness(flowData));
419+
this.insertLog(AippInstLogType.ERROR.name(), logData, DataUtils.getBusiness(flowData));
420420
}
421421

422422
/**
@@ -512,13 +512,4 @@ public void deleteLogs(List<Long> logIds) {
512512
}
513513
this.aippLogMapper.deleteInstanceLogs(logIds);
514514
}
515-
516-
@Override
517-
public void insertLog(String logType, AippLogData logData, Map<String, Object> businessData) {
518-
AippLogCreateDto logCreateDto = this.buildAippLogCreateDto(logType, logData, businessData);
519-
if (logCreateDto == null) {
520-
return;
521-
}
522-
this.aippLogMapper.insertOne(logCreateDto);
523-
}
524515
}

app-builder/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
@@ -83,5 +83,10 @@
8383
"type": "textConcatenateNodeState",
8484
"name": "Text Joiner",
8585
"uniqueName": ""
86+
},
87+
{
88+
"type": "replyNodeState",
89+
"name": "Reply",
90+
"uniqueName": ""
8691
}
8792
]

0 commit comments

Comments
 (0)