-
Notifications
You must be signed in to change notification settings - Fork 232
[app-builder] add reply node #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
loveTsong
merged 3 commits into
ModelEngine-Group:main
from
reeeborn33:appbuilder-feature-reply-node
Oct 10, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ilder/plugins/aipp-plugin/src/main/java/modelengine/fit/jober/aipp/fitable/ReplyNode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved. | ||
| * This file is a part of the ModelEngine Project. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| package modelengine.fit.jober.aipp.fitable; | ||
|
|
||
| import modelengine.fit.jade.aipp.template.render.TemplateService; | ||
| import modelengine.fit.jober.aipp.entity.AippLogData; | ||
| import modelengine.fit.jober.aipp.enums.AippInstLogType; | ||
| import modelengine.fit.jober.aipp.service.AippLogService; | ||
| import modelengine.fit.jober.aipp.util.DataUtils; | ||
| import modelengine.fit.waterflow.spi.FlowableService; | ||
| import modelengine.fitframework.annotation.Component; | ||
| import modelengine.fitframework.annotation.Fitable; | ||
| import modelengine.fitframework.util.ObjectUtils; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * 直接回复节点实现 | ||
| * | ||
| * @author 孙怡菲 | ||
| * @since 2025-09-11 | ||
| */ | ||
| @Component | ||
| public class ReplyNode implements FlowableService { | ||
| private final static String TEMPLATE_KEY = "template"; | ||
|
|
||
| private final static String VARIABLES_KEY = "variables"; | ||
|
|
||
| private final AippLogService aippLogService; | ||
|
|
||
| private final TemplateService templateService; | ||
|
|
||
| public ReplyNode(AippLogService aippLogService, TemplateService templateService) { | ||
| this.aippLogService = aippLogService; | ||
| this.templateService = templateService; | ||
| } | ||
|
|
||
| @Override | ||
| @Fitable("modelengine.fit.jober.aipp.fitable.ReplyNodeComponent") | ||
| public List<Map<String, Object>> handleTask(List<Map<String, Object>> flowData) { | ||
| Map<String, Object> businessData = DataUtils.getBusiness(flowData); | ||
| String template = ObjectUtils.cast(businessData.get(TEMPLATE_KEY)); | ||
| Map<String, Object> args = ObjectUtils.cast(businessData.get(VARIABLES_KEY)); | ||
| String msg = this.templateService.renderTemplate(template, args); | ||
| this.sendMsg(msg, businessData); | ||
| return flowData; | ||
| } | ||
|
|
||
| private void sendMsg(String msg, Map<String, Object> businessData) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| this.aippLogService.insertLog(AippInstLogType.MSG.name(), | ||
| AippLogData.builder().msg(msg).build(), | ||
| businessData); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...r/plugins/aipp-plugin/src/test/java/modelengine/fit/jober/aipp/fitable/ReplyNodeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved. | ||
| * This file is a part of the ModelEngine Project. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| package modelengine.fit.jober.aipp.fitable; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.mockito.ArgumentMatchers.eq; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.times; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import modelengine.fit.jade.aipp.template.render.TemplateService; | ||
| import modelengine.fit.jober.aipp.entity.AippLogData; | ||
| import modelengine.fit.jober.aipp.enums.AippInstLogType; | ||
| import modelengine.fit.jober.aipp.service.AippLogService; | ||
|
|
||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.ArgumentCaptor; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * {@link ReplyNode}的测试用例。 | ||
| * | ||
| * @author 孙怡菲 | ||
| * @since 2025-09-17 | ||
| */ | ||
| class ReplyNodeTest { | ||
| private AippLogService aippLogService; | ||
| private TemplateService templateService; | ||
| private ReplyNode replyNode; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| this.aippLogService = mock(AippLogService.class); | ||
| this.templateService = mock(TemplateService.class); | ||
| this.replyNode = new ReplyNode(this.aippLogService, this.templateService); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldOkAndInsertLog() { | ||
| Map<String, Object> businessData = new HashMap<>(); | ||
| String template = "你好,{{name}},欢迎回来!"; | ||
| String expectedMsg = "你好,小明,欢迎回来"; | ||
| businessData.put("template", template); | ||
| Map<String, Object> variables = new HashMap<>(); | ||
| variables.put("name", "小明"); | ||
| businessData.put("variables", variables); | ||
|
|
||
| List<Map<String, Object>> flowData = new ArrayList<>(); | ||
| Map<String, Object> flowItem = new HashMap<>(); | ||
| flowItem.put("businessData", businessData); | ||
| flowData.add(flowItem); | ||
|
|
||
| when(templateService.renderTemplate(template, variables)).thenReturn(expectedMsg); | ||
|
|
||
| List<Map<String, Object>> result = this.replyNode.handleTask(flowData); | ||
|
|
||
| assertEquals(flowData, result); | ||
|
|
||
| ArgumentCaptor<AippLogData> logCaptor = ArgumentCaptor.forClass(AippLogData.class); | ||
| verify(this.aippLogService, times(1)).insertLog( | ||
| eq(AippInstLogType.MSG.name()), | ||
| logCaptor.capture(), | ||
| eq(businessData) | ||
| ); | ||
|
|
||
| AippLogData logData = logCaptor.getValue(); | ||
| assertNotNull(logData); | ||
| assertEquals(expectedMsg, logData.getMsg()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.