Allow tool registration on swipes

This commit is contained in:
Cohee 2024-10-06 22:25:23 +03:00
parent 6b022e783d
commit 89bad21881
2 changed files with 3 additions and 3 deletions

View File

@ -4472,7 +4472,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
if (canPerformToolCalls && isStreamFinished && isStreamWithToolCalls) {
const lastMessage = chat[chat.length - 1];
const hasToolCalls = ToolManager.hasToolCalls(streamingProcessor.toolCalls);
const shouldDeleteMessage = ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor?.result);
const shouldDeleteMessage = type !== 'swipe' && ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor?.result);
hasToolCalls && shouldDeleteMessage && await deleteLastMessage();
const invocationResult = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls);
if (hasToolCalls) {
@ -4566,7 +4566,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
if (canPerformToolCalls) {
const hasToolCalls = ToolManager.hasToolCalls(data);
const shouldDeleteMessage = ['', '...'].includes(getMessage);
const shouldDeleteMessage = type !== 'swipe' && ['', '...'].includes(getMessage);
hasToolCalls && shouldDeleteMessage && await deleteLastMessage();
const invocationResult = await ToolManager.invokeFunctionTools(data);
if (hasToolCalls) {

View File

@ -487,7 +487,7 @@ export class ToolManager {
* @returns {boolean} Whether tool calls can be performed for the given type
*/
static canPerformToolCalls(type) {
const noToolCallTypes = ['swipe', 'impersonate', 'quiet', 'continue'];
const noToolCallTypes = ['impersonate', 'quiet', 'continue'];
const isSupported = ToolManager.isToolCallingSupported();
return isSupported && !noToolCallTypes.includes(type);
}