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