mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-09 08:38:53 +01:00
Defaulting to -1 rather than boolean false
This commit is contained in:
parent
ac33e4d668
commit
5397614347
@ -174,6 +174,7 @@ claude:
|
||||
# Use with caution. Behavior may be unpredictable and no guarantees can or will be made.
|
||||
# Set to an integer to specify the desired depth. 0 (which does NOT include the prefill)
|
||||
# should be ideal for most use cases.
|
||||
cachingAtDepth: false
|
||||
# Any value other than a non-negative integer will be ignored and caching at depth will not be enabled.
|
||||
cachingAtDepth: -1
|
||||
# -- SERVER PLUGIN CONFIGURATION --
|
||||
enableServerPlugins: false
|
||||
|
@ -80,7 +80,11 @@ async function sendClaudeRequest(request, response) {
|
||||
const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.CLAUDE);
|
||||
const divider = '-'.repeat(process.stdout.columns);
|
||||
const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false) && request.body.model.startsWith('claude-3');
|
||||
let cachingAtDepth = getConfigValue('claude.cachingAtDepth', false) && request.body.model.startsWith('claude-3');
|
||||
let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1) && request.body.model.startsWith('claude-3');
|
||||
// Disabled if not an integer or negative
|
||||
if (!Number.isInteger(cachingAtDepth) || cachingAtDepth < 0) {
|
||||
cachingAtDepth = -1;
|
||||
}
|
||||
|
||||
if (!apiKey) {
|
||||
console.log(color.red(`Claude API key is missing.\n${divider}`));
|
||||
@ -140,7 +144,7 @@ async function sendClaudeRequest(request, response) {
|
||||
}
|
||||
}
|
||||
|
||||
if (cachingAtDepth !== false) {
|
||||
if (cachingAtDepth !== -1) {
|
||||
// There are extremely few scenarios in which caching the prefill is a good idea, it mostly just breaks everything
|
||||
const messageCount = convertedPrompt.messages.length;
|
||||
cachingAtDepth += convertedPrompt.messages[messageCount - 1].role === 'assistant' ? 1 : 0;
|
||||
@ -156,7 +160,7 @@ async function sendClaudeRequest(request, response) {
|
||||
}
|
||||
}
|
||||
|
||||
if (enableSystemPromptCache || cachingAtDepth !== false) {
|
||||
if (enableSystemPromptCache || cachingAtDepth !== -1) {
|
||||
additionalHeaders['anthropic-beta'] = 'prompt-caching-2024-07-31';
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user