优化: Anthropic prompt 缓存默认开启

- 默认开(原默认关): 长会话显式缓存断点省 token, 按端点类型自动判定
- 仅支持缓存的端点生效, 其余零影响; 网关异常可手动关闭回退
This commit is contained in:
lxy
2026-10-11 07:38:01 +08:00
parent 3818a63522
commit cd77c1d6c7
3 changed files with 10 additions and 9 deletions
+6 -5
View File
@@ -33,8 +33,9 @@
@providers-changed="onProvidersChanged"
/>
<!-- AI Prompt 缓存总开关(KV df-ai-anthropic-cache,默认关;后端每请求读 settings,改后即时生效)
开:Anthropic 协议端点 system+历史段显式缓存断点;openai_compat 前缀稳定拆分(易变段挪消息流末尾) -->
<!-- AI Prompt 缓存总开关(KV df-ai-anthropic-cache,默认开;后端每请求读 settings,改后即时生效)
开:Anthropic 协议端点 system+历史段显式缓存断点;openai_compat 前缀稳定拆分(易变段挪消息流末尾);
后端按 provider_type 自动 gate,不支持的端点零影响。关 = 用户显式回退旧行为 -->
<section v-if="activeCategory === 'ai-model'" class="panel">
<div class="panel-header">
<h2>{{ $t('settings.panelAnthropicCache') }}</h2>
@@ -168,9 +169,9 @@ onBeforeRouteLeave(async () => {
return await confirmLeaveIfProviderDirty()
})
// AI Prompt 缓存总开关(KV df-ai-anthropic-cache,默认关,与后端 prompt.rs cache_enabled 同键;
// 值落库为 JSON 布尔,后端 "true"/"1" 判定兼容)
const anthropicCache = appSettings.useSetting<boolean>('df-ai-anthropic-cache', false)
// AI Prompt 缓存总开关(KV df-ai-anthropic-cache,默认开,与后端 prompt.rs parse_cache_flag 同键同默认;
// 值落库为 JSON 布尔,后端 "true"/"1" 判定兼容,显式 "false" 为用户回退)
const anthropicCache = appSettings.useSetting<boolean>('df-ai-anthropic-cache', true)
// 走查 P3-11:原开关切换零反馈,用户无从得知是否生效。改为 set 完成后 toast 反馈成败。
// 注:appSettings.set 当前落库失败仅 console 内吞(降级内存态),catch 是 store 上抛错误后