| 4409 | } | 4409 | } |
| 4410 | | 4410 | |
| 4411 | if (canPerformToolCalls && Array.isArray(streamingProcessor.toolCalls) && streamingProcessor.toolCalls.length) { | 4411 | if (canPerformToolCalls && Array.isArray(streamingProcessor.toolCalls) && streamingProcessor.toolCalls.length) { |
| | 4412 | const lastMessage = chat[chat.length - 1]; |
| | 4413 | const shouldDeleteMessage = ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor.result); |
| | 4414 | shouldDeleteMessage && await deleteLastMessage(); |
| 4412 | const invocations = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls); | 4415 | const invocations = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls); |
| 4413 | if (Array.isArray(invocations) && invocations.length) { | 4416 | if (Array.isArray(invocations) && invocations.length) { |
| 4414 | const lastMessage = chat[chat.length - 1]; | 4417 | streamingProcessor = null; |
| 4415 | const shouldDeleteMessage = ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor.result); | | |
| 4416 | if (shouldDeleteMessage) { | | |
| 4417 | await deleteLastMessage(); | | |
| 4418 | streamingProcessor = null; | | |
| 4419 | } | | |
| 4420 | ToolManager.saveFunctionToolInvocations(invocations); | 4418 | ToolManager.saveFunctionToolInvocations(invocations); |
| 4421 | return Generate(type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage, quietName }, dryRun); | 4419 | return Generate(type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage, quietName }, dryRun); |
| 4422 | } | 4420 | } |