@@ -213,21 +213,10 @@ export const getChatSourceByPublishChannel = (publishChannel: PublishChannelEnum
213213export const mergeChatResponseData = (
214214 responseDataList : ChatHistoryItemResType [ ]
215215) : ChatHistoryItemResType [ ] => {
216- // Merge children reponse data(Children has interactive response)
217- const responseWithMergedPlugins = responseDataList . map ( ( item ) => {
218- if ( item . pluginDetail && item . pluginDetail . length > 1 ) {
219- return {
220- ...item ,
221- pluginDetail : mergeChatResponseData ( item . pluginDetail )
222- } ;
223- }
224- return item ;
225- } ) ;
226-
227216 const result : ChatHistoryItemResType [ ] = [ ] ;
228217 const mergeMap = new Map < string , number > ( ) ; // mergeSignId -> result index
229218
230- for ( const item of responseWithMergedPlugins ) {
219+ for ( const item of responseDataList ) {
231220 if ( item . mergeSignId && mergeMap . has ( item . mergeSignId ) ) {
232221 // Merge with existing item
233222 const existingIndex = mergeMap . get ( item . mergeSignId ) ! ;
@@ -238,9 +227,18 @@ export const mergeChatResponseData = (
238227 runningTime : + ( ( existing . runningTime || 0 ) + ( item . runningTime || 0 ) ) . toFixed ( 2 ) ,
239228 totalPoints : ( existing . totalPoints || 0 ) + ( item . totalPoints || 0 ) ,
240229 childTotalPoints : ( existing . childTotalPoints || 0 ) + ( item . childTotalPoints || 0 ) ,
241- toolDetail : [ ...( existing . toolDetail || [ ] ) , ...( item . toolDetail || [ ] ) ] ,
242- loopDetail : [ ...( existing . loopDetail || [ ] ) , ...( item . loopDetail || [ ] ) ] ,
243- pluginDetail : [ ...( existing . pluginDetail || [ ] ) , ...( item . pluginDetail || [ ] ) ]
230+ toolDetail : mergeChatResponseData ( [
231+ ...( existing . toolDetail || [ ] ) ,
232+ ...( item . toolDetail || [ ] )
233+ ] ) ,
234+ loopDetail : mergeChatResponseData ( [
235+ ...( existing . loopDetail || [ ] ) ,
236+ ...( item . loopDetail || [ ] )
237+ ] ) ,
238+ pluginDetail : mergeChatResponseData ( [
239+ ...( existing . pluginDetail || [ ] ) ,
240+ ...( item . pluginDetail || [ ] )
241+ ] )
244242 } ;
245243 } else {
246244 // Add new item
0 commit comments