优化: Anthropic prompt 缓存默认开启
- 默认开(原默认关): 长会话显式缓存断点省 token, 按端点类型自动判定 - 仅支持缓存的端点生效, 其余零影响; 网关异常可手动关闭回退
This commit is contained in:
@@ -256,10 +256,10 @@ export default {
|
|||||||
pathAuthBypassConfirmTitle: 'Enable "Trust all directories"?',
|
pathAuthBypassConfirmTitle: 'Enable "Trust all directories"?',
|
||||||
pathAuthBypassConfirmBody: 'Once enabled, AI tools will no longer ask for per-access authorization and can directly reach any path, including sensitive directories such as .ssh and .aws. Sensitive credentials may end up in the conversation context; proceed at your own risk. Are you sure you want to enable it?',
|
pathAuthBypassConfirmBody: 'Once enabled, AI tools will no longer ask for per-access authorization and can directly reach any path, including sensitive directories such as .ssh and .aws. Sensitive credentials may end up in the conversation context; proceed at your own risk. Are you sure you want to enable it?',
|
||||||
|
|
||||||
// Anthropic prompt caching (Settings - AI Model; KV df-ai-anthropic-cache, default off, effective immediately)
|
// Anthropic prompt caching (Settings - AI Model; KV df-ai-anthropic-cache, default on, effective immediately)
|
||||||
panelAnthropicCache: 'AI Prompt Caching',
|
panelAnthropicCache: 'AI Prompt Caching',
|
||||||
labelAnthropicCache: 'Enable prompt caching',
|
labelAnthropicCache: 'Enable prompt caching',
|
||||||
descAnthropicCache: 'When enabled, Anthropic-protocol endpoints get explicit cache breakpoints on the system prompt and conversation history, greatly reducing token cost for long sessions; OpenAI-compatible endpoints also get prefix-stable splitting (volatile content moves to the end of the message stream so automatic prefix caches can hit). Only enable for endpoints that support caching; gateways without support may reject the cache_control field.',
|
descAnthropicCache: 'On by default: Anthropic-protocol endpoints get explicit cache breakpoints on the system prompt and conversation history, greatly reducing token cost for long sessions; OpenAI-compatible endpoints also get prefix-stable splitting (volatile content moves to the end of the message stream so automatic prefix caches can hit). Applies only to endpoints that support caching (detected by endpoint type) and has zero impact on others; turn it off here to roll back if a gateway misbehaves.',
|
||||||
|
|
||||||
// ===== ScriptNode command execution safety =====
|
// ===== ScriptNode command execution safety =====
|
||||||
panelScriptSafety: '🛡️ Command Execution Safety',
|
panelScriptSafety: '🛡️ Command Execution Safety',
|
||||||
|
|||||||
@@ -255,10 +255,10 @@ export default {
|
|||||||
pathAuthBypassConfirmTitle: '开启「信任所有目录」?',
|
pathAuthBypassConfirmTitle: '开启「信任所有目录」?',
|
||||||
pathAuthBypassConfirmBody: '开启后 AI 工具将无需逐次授权,直接访问包括 .ssh、.aws 等敏感目录在内的任意路径,敏感凭据可能进入对话上下文,风险自担。确定开启?',
|
pathAuthBypassConfirmBody: '开启后 AI 工具将无需逐次授权,直接访问包括 .ssh、.aws 等敏感目录在内的任意路径,敏感凭据可能进入对话上下文,风险自担。确定开启?',
|
||||||
|
|
||||||
// Anthropic prompt caching(设置-AI 模型;KV df-ai-anthropic-cache,默认关,改后即时生效)
|
// Anthropic prompt caching(设置-AI 模型;KV df-ai-anthropic-cache,默认开,改后即时生效)
|
||||||
panelAnthropicCache: 'AI Prompt 缓存',
|
panelAnthropicCache: 'AI Prompt 缓存',
|
||||||
labelAnthropicCache: '启用 prompt 缓存',
|
labelAnthropicCache: '启用 prompt 缓存',
|
||||||
descAnthropicCache: '开启后 Anthropic 协议端点在 system 与历史段打显式缓存断点,长会话显著省 token;OpenAI 兼容端点同时启用前缀稳定拆分(易变内容挪到消息流末尾,自动前缀缓存可命中)。仅对支持缓存的端点开启,不支持的网关可能拒收 cache_control 字段。',
|
descAnthropicCache: '默认开启:Anthropic 协议端点在 system 与历史段打显式缓存断点,长会话显著省 token;OpenAI 兼容端点同时启用前缀稳定拆分(易变内容挪到消息流末尾,自动前缀缓存可命中)。仅对支持缓存的端点生效(按端点类型自动判定),其余端点零影响;如遇网关异常可在此关闭回退。',
|
||||||
|
|
||||||
// ===== ScriptNode 命令执行安全 =====
|
// ===== ScriptNode 命令执行安全 =====
|
||||||
panelScriptSafety: '🛡️ 命令执行安全',
|
panelScriptSafety: '🛡️ 命令执行安全',
|
||||||
|
|||||||
@@ -33,8 +33,9 @@
|
|||||||
@providers-changed="onProvidersChanged"
|
@providers-changed="onProvidersChanged"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- AI Prompt 缓存总开关(KV df-ai-anthropic-cache,默认关;后端每请求读 settings,改后即时生效)
|
<!-- AI Prompt 缓存总开关(KV df-ai-anthropic-cache,默认开;后端每请求读 settings,改后即时生效)
|
||||||
开:Anthropic 协议端点 system+历史段显式缓存断点;openai_compat 前缀稳定拆分(易变段挪消息流末尾) -->
|
开:Anthropic 协议端点 system+历史段显式缓存断点;openai_compat 前缀稳定拆分(易变段挪消息流末尾);
|
||||||
|
后端按 provider_type 自动 gate,不支持的端点零影响。关 = 用户显式回退旧行为 -->
|
||||||
<section v-if="activeCategory === 'ai-model'" class="panel">
|
<section v-if="activeCategory === 'ai-model'" class="panel">
|
||||||
<div class="panel-header">
|
<div class="panel-header">
|
||||||
<h2>{{ $t('settings.panelAnthropicCache') }}</h2>
|
<h2>{{ $t('settings.panelAnthropicCache') }}</h2>
|
||||||
@@ -168,9 +169,9 @@ onBeforeRouteLeave(async () => {
|
|||||||
return await confirmLeaveIfProviderDirty()
|
return await confirmLeaveIfProviderDirty()
|
||||||
})
|
})
|
||||||
|
|
||||||
// AI Prompt 缓存总开关(KV df-ai-anthropic-cache,默认关,与后端 prompt.rs cache_enabled 同键;
|
// AI Prompt 缓存总开关(KV df-ai-anthropic-cache,默认开,与后端 prompt.rs parse_cache_flag 同键同默认;
|
||||||
// 值落库为 JSON 布尔,后端 "true"/"1" 判定兼容)
|
// 值落库为 JSON 布尔,后端 "true"/"1" 判定兼容,显式 "false" 为用户回退)
|
||||||
const anthropicCache = appSettings.useSetting<boolean>('df-ai-anthropic-cache', false)
|
const anthropicCache = appSettings.useSetting<boolean>('df-ai-anthropic-cache', true)
|
||||||
|
|
||||||
// 走查 P3-11:原开关切换零反馈,用户无从得知是否生效。改为 set 完成后 toast 反馈成败。
|
// 走查 P3-11:原开关切换零反馈,用户无从得知是否生效。改为 set 完成后 toast 反馈成败。
|
||||||
// 注:appSettings.set 当前落库失败仅 console 内吞(降级内存态),catch 是 store 上抛错误后
|
// 注:appSettings.set 当前落库失败仅 console 内吞(降级内存态),catch 是 store 上抛错误后
|
||||||
|
|||||||
Reference in New Issue
Block a user