Tool Calling: Implement stealth tool defintions (#3192)

* Tool Calling: Implement stealth tool defintions

* Move isStealth check up

* Always stop generation on stealth tool calls

* Image Generation: use stealth flag for tool registration

* Update stealth property description to clarify no follow-up generation will be performed

* Revert "Image Generation: use stealth flag for tool registration"

This reverts commit 8d13445c0b.
This commit is contained in:
Cohee
2024-12-19 21:17:47 +02:00
committed by GitHub
parent e83182c03b
commit 7e7b3e30c4
2 changed files with 68 additions and 9 deletions

View File

@ -4579,9 +4579,12 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
const shouldDeleteMessage = type !== 'swipe' && ['', '...'].includes(lastMessage?.mes) && ['', '...'].includes(streamingProcessor?.result);
hasToolCalls && shouldDeleteMessage && await deleteLastMessage();
const invocationResult = await ToolManager.invokeFunctionTools(streamingProcessor.toolCalls);
const shouldStopGeneration = (!invocationResult.invocations.length && shouldDeleteMessage) || invocationResult.stealthCalls.length;
if (hasToolCalls) {
if (!invocationResult.invocations.length && shouldDeleteMessage) {
ToolManager.showToolCallError(invocationResult.errors);
if (shouldStopGeneration) {
if (Array.isArray(invocationResult.errors) && invocationResult.errors.length) {
ToolManager.showToolCallError(invocationResult.errors);
}
unblockGeneration(type);
generatedPromptCache = '';
streamingProcessor = null;
@ -4681,9 +4684,12 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
const shouldDeleteMessage = type !== 'swipe' && ['', '...'].includes(getMessage);
hasToolCalls && shouldDeleteMessage && await deleteLastMessage();
const invocationResult = await ToolManager.invokeFunctionTools(data);
const shouldStopGeneration = (!invocationResult.invocations.length && shouldDeleteMessage) || invocationResult.stealthCalls.length;
if (hasToolCalls) {
if (!invocationResult.invocations.length && shouldDeleteMessage) {
ToolManager.showToolCallError(invocationResult.errors);
if (shouldStopGeneration) {
if (Array.isArray(invocationResult.errors) && invocationResult.errors.length) {
ToolManager.showToolCallError(invocationResult.errors);
}
unblockGeneration(type);
generatedPromptCache = '';
return;