Skip to content

Commit 3c9deb6

Browse files
committed
Merge branch '1.2.x'
2 parents f36cc9b + 038e720 commit 3c9deb6

File tree

6 files changed

+36
-7
lines changed

6 files changed

+36
-7
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package modelengine.fit.jober.aipp.fitable;
88

99
import static modelengine.fit.jade.aipp.prompt.constant.Constant.PROMPT_METADATA_KEY;
10+
import static modelengine.fit.jober.aipp.constants.AippConst.INST_STATUS_KEY;
1011
import static modelengine.fitframework.inspection.Validation.notNull;
1112

1213
import modelengine.fel.core.chat.ChatMessage;
@@ -23,6 +24,7 @@
2324
import modelengine.fel.tool.mcp.client.McpClientFactory;
2425
import modelengine.fel.tool.mcp.entity.Tool;
2526
import modelengine.fel.tool.model.transfer.ToolData;
27+
import modelengine.fit.jober.aipp.enums.MetaInstStatusEnum;
2628
import modelengine.fit.jober.aipp.util.McpUtils;
2729
import modelengine.fitframework.inspection.Validation;
2830
import modelengine.jade.store.service.ToolService;
@@ -279,7 +281,9 @@ private void addAnswer(AippLlmMeta llmMeta, String answer, Map<String, Object> p
279281

280282
// 如果节点配置为输出到聊天,模型回复内容需要持久化
281283
boolean enableLog = checkEnableLog(businessData);
282-
if (enableLog) {
284+
AppTaskInstance instance =
285+
this.appTaskInstanceService.getInstance(llmMeta.getVersionId(), llmMeta.getInstId(), null).orElse(null);
286+
if (enableLog && ! this.isTerminated(instance)) {
283287
Map<String, Object> llmOutput = new HashMap<>();
284288
llmOutput.put("output", output);
285289
Optional<ResponsibilityResult> formatOutput = this.formatterChain.handle(llmOutput);
@@ -299,6 +303,15 @@ private void addAnswer(AippLlmMeta llmMeta, String answer, Map<String, Object> p
299303
doOnAgentComplete(llmMeta);
300304
}
301305

306+
private boolean isTerminated(AppTaskInstance instance) {
307+
if (instance == null) {
308+
return false;
309+
}
310+
Map<String, Object> infos = instance.getEntity().getInfos();
311+
return infos != null && StringUtils.equals(ObjectUtils.cast(infos.get(INST_STATUS_KEY)),
312+
MetaInstStatusEnum.TERMINATED.name());
313+
}
314+
302315
/**
303316
* llm节点处理结束回调函数。
304317
* <ul>

frontend/src/pages/chatPreview/components/receive-box/message-detail.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import ThinkBlock from './think-block';
1717
import StepBlock from './step-block';
1818
import 'highlight.js/styles/monokai-sublime.min.css';
1919
import './styles/message-detail.scss';
20+
import store from '@/store/store';
21+
import {setCurrentAnswer} from "@/store/chatStore/chatStore";
2022

2123
/**
2224
* 消息详情
@@ -205,6 +207,10 @@ const MessageBox = (props: any) => {
205207
container && container.removeEventListener('click', recieveClick);
206208
}
207209
}, []);
210+
211+
useEffect(() => {
212+
store.dispatch(setCurrentAnswer(replacedText));
213+
}, [replacedText]);
208214

209215
return (
210216
<>

frontend/src/pages/chatPreview/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const ChatPreview = (props) => {
8383
const showMulti = useAppSelector((state) => state.commonStore.historySwitch);
8484
const useMemory = useAppSelector((state) => state.commonStore.useMemory);
8585
const isDebug = useAppSelector((state) => state.commonStore.isDebug);
86+
const currentAnswer = useAppSelector((state) => state.chatCommonStore.currentAnswer);
8687
const { showElsa } = useContext(AippContext);
8788
const [checkedList, setCheckedList] = useState([]);
8889
const [loading, setLoading] = useState(false);
@@ -594,8 +595,8 @@ const ChatPreview = (props) => {
594595
// 终止进行中的对话
595596
async function chatRunningStop(params) {
596597
let terminateParams: any = {};
597-
params.content ? terminateParams.content = params.content : terminateParams.content = t('conversationTerminated');
598-
params.instanceId ? runningInstanceId.current = params.instanceId : '';
598+
terminateParams.content = params.content ? params.content : currentAnswer ? currentAnswer :
599+
t('conversationTerminated');
599600
if (params.logId) {
600601
terminateParams.logId = params.logId;
601602
}

frontend/src/store/chatStore/action-types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export const SET_REFERENCE_LIST = 'SET_REFERENCE_LIST';
1212
export const SET_USER_ROLE = 'SET_USER_ROLE';
1313
export const SET_READ_ONLY = 'SET_READ_ONLY';
1414
export const SET_NO_AUTH = 'SET_NO_AUTH';
15-
export const SET_PLUGIN_LIST = 'SET_PLUGIN_LIST';
15+
export const SET_PLUGIN_LIST = 'SET_PLUGIN_LIST';
16+
export const SET_CURRENT_ANSWER = 'SET_CURRENT_ANSWER';

frontend/src/store/chatStore/chatStore.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
SET_READ_ONLY,
1414
SET_NO_AUTH,
1515
SET_USER_ROLE,
16-
SET_PLUGIN_LIST
16+
SET_PLUGIN_LIST,
17+
SET_CURRENT_ANSWER
1718
} from './action-types';
1819

1920
export const setChatId = (item) => {
@@ -60,4 +61,7 @@ export const setNoAuth = (item) => {
6061
}
6162
export const setPluginList = (item) => {
6263
return { type: SET_PLUGIN_LIST, payload: item }
63-
}
64+
}
65+
export const setCurrentAnswer = (item) => {
66+
return { type: SET_CURRENT_ANSWER, payload: item }
67+
}

frontend/src/store/chatStore/reducer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
SET_USER_ROLE,
1414
SET_READ_ONLY,
1515
SET_NO_AUTH,
16-
SET_PLUGIN_LIST
16+
SET_PLUGIN_LIST,
17+
SET_CURRENT_ANSWER
1718
} from './action-types';
1819

1920
const initialState = {
@@ -32,6 +33,7 @@ const initialState = {
3233
readOnly: false,
3334
noAuth: false,
3435
pluginList: [],
36+
currentAnswer: ''
3537
}
3638

3739
const chatReducers = (state = initialState, action) => {
@@ -66,6 +68,8 @@ const chatReducers = (state = initialState, action) => {
6668
return { ...state, noAuth: action.payload };
6769
case SET_PLUGIN_LIST:
6870
return { ...state, pluginList: action.payload };
71+
case SET_CURRENT_ANSWER:
72+
return { ...state, currentAnswer: action.payload };
6973
default:
7074
return state
7175
}

0 commit comments

Comments
 (0)