mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-29 04:10:00 +08:00
feat(hermes): add prompt caching settings
This commit is contained in:
@@ -139,6 +139,15 @@ test('Hermes 配置页会暴露全局显示与可靠性结构化配置字段', (
|
||||
}
|
||||
})
|
||||
|
||||
test('Hermes 配置页会暴露提示缓存结构化配置字段', () => {
|
||||
for (const id of [
|
||||
'hm-prompt-caching-save',
|
||||
'hm-prompt-cache-ttl',
|
||||
]) {
|
||||
assert.match(source, new RegExp(`id="${id}"`), `缺少 ${id}`)
|
||||
}
|
||||
})
|
||||
|
||||
test('Hermes 配置页会暴露网关流式结构化配置字段', () => {
|
||||
for (const id of [
|
||||
'hm-streaming-save',
|
||||
@@ -290,6 +299,7 @@ test('Hermes 配置页新增结构化配置不会暴露翻译 key', () => {
|
||||
key.includes('SecurityConfig') ||
|
||||
key.includes('HumanDelayConfig') ||
|
||||
key.includes('DisplayConfig') ||
|
||||
key.includes('PromptCachingConfig') ||
|
||||
key.includes('StreamingConfig') ||
|
||||
key.includes('ExecutionLimits') ||
|
||||
key.includes('PrivacyConfig') ||
|
||||
|
||||
50
tests/hermes-prompt-caching-config.test.js
Normal file
50
tests/hermes-prompt-caching-config.test.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import {
|
||||
buildHermesPromptCachingConfigValues,
|
||||
mergeHermesPromptCachingConfig,
|
||||
} from '../scripts/dev-api.js'
|
||||
|
||||
test('Hermes 提示缓存配置读取会提供上游默认 TTL', () => {
|
||||
const values = buildHermesPromptCachingConfigValues({})
|
||||
|
||||
assert.deepEqual(values, {
|
||||
promptCacheTtl: '5m',
|
||||
})
|
||||
})
|
||||
|
||||
test('Hermes 提示缓存配置读取会规范化 YAML 中的 TTL', () => {
|
||||
const values = buildHermesPromptCachingConfigValues({
|
||||
prompt_caching: {
|
||||
cache_ttl: '1H',
|
||||
},
|
||||
})
|
||||
|
||||
assert.equal(values.promptCacheTtl, '1h')
|
||||
})
|
||||
|
||||
test('Hermes 提示缓存配置保存会保留无关 YAML 和未知字段', () => {
|
||||
const next = mergeHermesPromptCachingConfig({
|
||||
model: { provider: 'anthropic' },
|
||||
prompt_caching: {
|
||||
cache_ttl: '5m',
|
||||
custom_flag: 'keep-prompt-cache',
|
||||
},
|
||||
compression: { enabled: true },
|
||||
}, {
|
||||
promptCacheTtl: '1h',
|
||||
})
|
||||
|
||||
assert.deepEqual(next.model, { provider: 'anthropic' })
|
||||
assert.deepEqual(next.compression, { enabled: true })
|
||||
assert.equal(next.prompt_caching.cache_ttl, '1h')
|
||||
assert.equal(next.prompt_caching.custom_flag, 'keep-prompt-cache')
|
||||
})
|
||||
|
||||
test('Hermes 提示缓存配置保存会拒绝上游不支持的 TTL', () => {
|
||||
assert.throws(
|
||||
() => mergeHermesPromptCachingConfig({}, { promptCacheTtl: '30m' }),
|
||||
/prompt_caching\.cache_ttl/,
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user