@@ -33,7 +33,8 @@ export const runToolCall = async (props: DispatchToolModuleProps): Promise<RunTo
3333 aiChatStopSign,
3434 aiChatResponseFormat,
3535 aiChatJsonSchema,
36- aiChatReasoning
36+ aiChatReasoning,
37+ isResponseAnswerText = true
3738 }
3839 } = workflowProps ;
3940
@@ -141,6 +142,7 @@ export const runToolCall = async (props: DispatchToolModuleProps): Promise<RunTo
141142 } ) ;
142143 } ,
143144 onStreaming ( { text } ) {
145+ if ( ! isResponseAnswerText ) return ;
144146 workflowStreamResponse ?.( {
145147 write,
146148 event : SseResponseEventEnum . answer ,
@@ -150,6 +152,7 @@ export const runToolCall = async (props: DispatchToolModuleProps): Promise<RunTo
150152 } ) ;
151153 } ,
152154 onToolCall ( { call } ) {
155+ if ( ! isResponseAnswerText ) return ;
153156 const toolNode = toolNodesMap . get ( call . function . name ) ;
154157 if ( toolNode ) {
155158 workflowStreamResponse ?.( {
@@ -168,6 +171,7 @@ export const runToolCall = async (props: DispatchToolModuleProps): Promise<RunTo
168171 }
169172 } ,
170173 onToolParam ( { tool, params } ) {
174+ if ( ! isResponseAnswerText ) return ;
171175 workflowStreamResponse ?.( {
172176 write,
173177 event : SseResponseEventEnum . toolParams ,
@@ -209,18 +213,20 @@ export const runToolCall = async (props: DispatchToolModuleProps): Promise<RunTo
209213 // Format tool response
210214 const stringToolResponse = formatToolResponse ( toolRunResponse . toolResponses ) ;
211215
212- workflowStreamResponse ?.( {
213- event : SseResponseEventEnum . toolResponse ,
214- data : {
215- tool : {
216- id : call . id ,
217- toolName : '' ,
218- toolAvatar : '' ,
219- params : '' ,
220- response : sliceStrStartEnd ( stringToolResponse , 5000 , 5000 )
216+ if ( isResponseAnswerText ) {
217+ workflowStreamResponse ?.( {
218+ event : SseResponseEventEnum . toolResponse ,
219+ data : {
220+ tool : {
221+ id : call . id ,
222+ toolName : '' ,
223+ toolAvatar : '' ,
224+ params : '' ,
225+ response : sliceStrStartEnd ( stringToolResponse , 5000 , 5000 )
226+ }
221227 }
222- }
223- } ) ;
228+ } ) ;
229+ }
224230
225231 toolRunResponses . push ( toolRunResponse ) ;
226232
@@ -258,18 +264,20 @@ export const runToolCall = async (props: DispatchToolModuleProps): Promise<RunTo
258264 // console.dir(runtimeEdges, { depth: null });
259265 const stringToolResponse = formatToolResponse ( toolRunResponse . toolResponses ) ;
260266
261- workflowStreamResponse ?.( {
262- event : SseResponseEventEnum . toolResponse ,
263- data : {
264- tool : {
265- id : toolParams . toolCallId ,
266- toolName : '' ,
267- toolAvatar : '' ,
268- params : '' ,
269- response : sliceStrStartEnd ( stringToolResponse , 5000 , 5000 )
267+ if ( isResponseAnswerText ) {
268+ workflowStreamResponse ?.( {
269+ event : SseResponseEventEnum . toolResponse ,
270+ data : {
271+ tool : {
272+ id : toolParams . toolCallId ,
273+ toolName : '' ,
274+ toolAvatar : '' ,
275+ params : '' ,
276+ response : sliceStrStartEnd ( stringToolResponse , 5000 , 5000 )
277+ }
270278 }
271- }
272- } ) ;
279+ } ) ;
280+ }
273281
274282 toolRunResponses . push ( toolRunResponse ) ;
275283 const assistantMessages = chats2GPTMessages ( {
0 commit comments