@@ -34,7 +34,7 @@ import {
34
34
initToolNodes ,
35
35
parseToolArgs
36
36
} from '../utils' ;
37
- import { getFileReadTool , getTopAgentDefaultPrompt , StopAgentTool , SubAppIds } from './constants' ;
37
+ import { getFileReadTool , getTopAgentConstantPrompt , StopAgentTool , SubAppIds } from './constants' ;
38
38
import { runWorkflow } from '../..' ;
39
39
import type { ChatCompletionTool } from '@fastgpt/global/core/ai/type' ;
40
40
import type { ToolNodeItemType } from './type' ;
@@ -44,6 +44,8 @@ import { transferPlanAgent } from '../sub/plan';
44
44
import { transferModelAgent } from '../sub/model' ;
45
45
import { PlanAgentTool } from '../sub/plan/constants' ;
46
46
import { ModelAgentTool } from '../sub/model/constants' ;
47
+ import { getSubIdsByAgentSystem , parseAgentSystem } from './utils' ;
48
+ import { getChildAppPreviewNode } from '../../../../../core/app/plugin/controller' ;
47
49
48
50
export type DispatchAgentModuleProps = ModuleDispatchProps < {
49
51
[ NodeInputKeyEnum . history ] ?: ChatItemType [ ] ;
@@ -101,7 +103,8 @@ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise
101
103
}
102
104
103
105
// Init tool params
104
- const toolNodeIds = filterToolNodeIdByEdges ( { nodeId, edges : runtimeEdges } ) ;
106
+ // const toolNodeIds = filterToolNodeIdByEdges({ nodeId, edges: runtimeEdges });
107
+ const toolNodeIds = getSubIdsByAgentSystem ( systemPrompt ) ;
105
108
const toolNodes = getToolNodesByIds ( { toolNodeIds, runtimeNodes } ) ;
106
109
// TODO: 补充系统 agent
107
110
const toolNodesMap = new Map < string , ToolNodeItemType > ( ) ;
@@ -118,10 +121,12 @@ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise
118
121
119
122
const subApps = getSubApps ( { toolNodes, urls : fileLinks } ) ;
120
123
124
+ const combinedSystemPrompt = `${ parseAgentSystem ( { systemPrompt, toolNodesMap } ) } \n\n${ getTopAgentConstantPrompt ( ) } ` ;
125
+
121
126
// TODO: 把 files 加入 query 中。
122
127
const messages : ChatItemType [ ] = ( ( ) => {
123
128
const value : ChatItemType [ ] = [
124
- ...getSystemPrompt_ChatItemType ( systemPrompt || getTopAgentDefaultPrompt ( ) ) ,
129
+ ...getSystemPrompt_ChatItemType ( combinedSystemPrompt ) ,
125
130
// Add file input prompt to histories
126
131
...chatHistories ,
127
132
{
@@ -436,7 +441,7 @@ const getSubApps = ({
436
441
type : 'function' ,
437
442
function : {
438
443
name : item . nodeId ,
439
- description : item . intro || item . name ,
444
+ description : `调用 ${ item . flowNodeType } : ${ item . name || item . intro } 完成任务` ,
440
445
parameters : item . jsonSchema
441
446
}
442
447
} ;
@@ -459,7 +464,7 @@ const getSubApps = ({
459
464
type : 'function' ,
460
465
function : {
461
466
name : item . nodeId ,
462
- description : item . toolDescription || item . intro || item . name ,
467
+ description : `调用 ${ item . flowNodeType } : ${ item . name || item . toolDescription || item . intro } 完成任务` ,
463
468
parameters : {
464
469
type : 'object' ,
465
470
properties,
@@ -468,6 +473,7 @@ const getSubApps = ({
468
473
}
469
474
} ;
470
475
} ) ;
476
+ console . dir ( nodeTools , { depth : null } ) ;
471
477
472
478
return [ ...systemTools , ...nodeTools ] ;
473
479
} ;
0 commit comments