mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-20 21:41:32 +01:00
Tool Calling: Reserve prompt budget for tool definitions.
This commit is contained in:
parent
5d6d7568c3
commit
b0d0f2111b
@ -998,6 +998,15 @@ async function populateChatCompletion(prompts, chatCompletion, { bias, quietProm
|
||||
chatCompletion.insert(Message.fromPrompt(prompt), 'main', prompt.position);
|
||||
}
|
||||
|
||||
// Pre-allocation of tokens for tool data
|
||||
if (ToolManager.canPerformToolCalls(type)) {
|
||||
const toolData = {};
|
||||
await ToolManager.registerFunctionToolsOpenAI(toolData);
|
||||
const toolMessage = [{ role: 'user', content: JSON.stringify(toolData) }];
|
||||
const toolTokens = tokenHandler.count(toolMessage);
|
||||
chatCompletion.reserveBudget(toolTokens);
|
||||
}
|
||||
|
||||
// Add in-chat injections
|
||||
messages = populationInjectionPrompts(absolutePrompts, messages);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user