mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Show an error when all tools fail
This commit is contained in:
@@ -4420,10 +4420,18 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
const lastMessage = chat[chat.length - 1];
|
||||
const shouldDeleteMessage = ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor.result);
|
||||
shouldDeleteMessage && await deleteLastMessage();
|
||||
const invocations = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls);
|
||||
if (Array.isArray(invocations) && invocations.length) {
|
||||
const invocationResult = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls);
|
||||
if (invocationResult.hadToolCalls) {
|
||||
if (!invocationResult.invocations.length && shouldDeleteMessage) {
|
||||
ToolManager.showToolCallError(invocationResult.errors);
|
||||
unblockGeneration(type);
|
||||
generatedPromptCache = '';
|
||||
streamingProcessor = null;
|
||||
return;
|
||||
}
|
||||
|
||||
streamingProcessor = null;
|
||||
ToolManager.saveFunctionToolInvocations(invocations);
|
||||
ToolManager.saveFunctionToolInvocations(invocationResult.invocations);
|
||||
return Generate(type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage, quietName }, dryRun);
|
||||
}
|
||||
}
|
||||
@@ -4505,9 +4513,16 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
if (canPerformToolCalls) {
|
||||
const shouldDeleteMessage = ['', '...'].includes(getMessage);
|
||||
shouldDeleteMessage && await deleteLastMessage();
|
||||
const invocations = await ToolManager.invokeFunctionTools(data);
|
||||
if (Array.isArray(invocations) && invocations.length) {
|
||||
ToolManager.saveFunctionToolInvocations(invocations);
|
||||
const invocationResult = await ToolManager.invokeFunctionTools(data);
|
||||
if (invocationResult.hadToolCalls) {
|
||||
if (!invocationResult.invocations.length && shouldDeleteMessage) {
|
||||
ToolManager.showToolCallError(invocationResult.errors);
|
||||
unblockGeneration(type);
|
||||
generatedPromptCache = '';
|
||||
return;
|
||||
}
|
||||
|
||||
ToolManager.saveFunctionToolInvocations(invocationResult.invocations);
|
||||
return Generate(type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage, quietName }, dryRun);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user