Fix error on streaming if the processor was already destroyed

This commit is contained in:
Cohee 2024-10-04 12:00:20 +00:00
parent db04fff3df
commit 8c095f204a

View File

@ -4420,7 +4420,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
const invocationResult = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls);
if (invocationResult.hadToolCalls) {
const lastMessage = chat[chat.length - 1];
const shouldDeleteMessage = ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor.result);
const shouldDeleteMessage = ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor?.result);
shouldDeleteMessage && await deleteLastMessage();
if (!invocationResult.invocations.length && shouldDeleteMessage) {
ToolManager.showToolCallError(invocationResult.errors);