mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Only delete message if had successful tool calls
This commit is contained in:
@ -4417,11 +4417,11 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canPerformToolCalls && Array.isArray(streamingProcessor.toolCalls) && streamingProcessor.toolCalls.length) {
|
if (canPerformToolCalls && Array.isArray(streamingProcessor.toolCalls) && streamingProcessor.toolCalls.length) {
|
||||||
const lastMessage = chat[chat.length - 1];
|
|
||||||
const shouldDeleteMessage = ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor.result);
|
|
||||||
shouldDeleteMessage && await deleteLastMessage();
|
|
||||||
const invocationResult = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls);
|
const invocationResult = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls);
|
||||||
if (invocationResult.hadToolCalls) {
|
if (invocationResult.hadToolCalls) {
|
||||||
|
const lastMessage = chat[chat.length - 1];
|
||||||
|
const shouldDeleteMessage = ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor.result);
|
||||||
|
shouldDeleteMessage && await deleteLastMessage();
|
||||||
if (!invocationResult.invocations.length && shouldDeleteMessage) {
|
if (!invocationResult.invocations.length && shouldDeleteMessage) {
|
||||||
ToolManager.showToolCallError(invocationResult.errors);
|
ToolManager.showToolCallError(invocationResult.errors);
|
||||||
unblockGeneration(type);
|
unblockGeneration(type);
|
||||||
@ -4511,10 +4511,10 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canPerformToolCalls) {
|
if (canPerformToolCalls) {
|
||||||
const shouldDeleteMessage = ['', '...'].includes(getMessage);
|
|
||||||
shouldDeleteMessage && await deleteLastMessage();
|
|
||||||
const invocationResult = await ToolManager.invokeFunctionTools(data);
|
const invocationResult = await ToolManager.invokeFunctionTools(data);
|
||||||
if (invocationResult.hadToolCalls) {
|
if (invocationResult.hadToolCalls) {
|
||||||
|
const shouldDeleteMessage = ['', '...'].includes(getMessage);
|
||||||
|
shouldDeleteMessage && await deleteLastMessage();
|
||||||
if (!invocationResult.invocations.length && shouldDeleteMessage) {
|
if (!invocationResult.invocations.length && shouldDeleteMessage) {
|
||||||
ToolManager.showToolCallError(invocationResult.errors);
|
ToolManager.showToolCallError(invocationResult.errors);
|
||||||
unblockGeneration(type);
|
unblockGeneration(type);
|
||||||
|
Reference in New Issue
Block a user