mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
feat(signature): frontend UI + i18n for signature pool size
Adds a Signature Pool Size numeric input to the Rectifier settings section with a hint explaining the 0-vs-positive semantics. When pool size > 0, the Thinking Signature and API Key Signature toggle hints dynamically switch from "strip signatures and retry" to "replace with pooled signatures (pass through when pool is empty)", matching the runtime strategy swap. Includes both zh and en locale keys (poolSize, poolSizeHint, poolSizeUnit, thinkingSignatureHintPool, apikeySignatureHintPool) plus the signature_pool_size field in the TypeScript RectifierSettings interface and save payload.
This commit is contained in:
@@ -428,6 +428,12 @@ export interface RectifierSettings {
|
||||
thinking_budget_enabled: boolean
|
||||
apikey_signature_enabled: boolean
|
||||
apikey_signature_patterns: string[]
|
||||
/**
|
||||
* 签名池容量。0 = 关闭池化,签名错误时走"剥除 thinking 重试";
|
||||
* \>0 = 从正常响应抓取签名入池,签名错误时从池中取签名替换重试,
|
||||
* 池空直接透传错误(不回退剥除)。
|
||||
*/
|
||||
signature_pool_size: number
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4763,16 +4763,24 @@ export default {
|
||||
enabledHint: 'Master switch - disabling turns off all rectification features',
|
||||
thinkingSignature: 'Thinking Signature Rectifier',
|
||||
thinkingSignatureHint: 'Automatically strip signatures and retry when upstream returns thinking block signature validation errors',
|
||||
thinkingSignatureHintPool:
|
||||
'Automatically replace bad signatures with pooled ones when upstream returns thinking block signature validation errors (pass through original error when pool is empty)',
|
||||
thinkingBudget: 'Thinking Budget Rectifier',
|
||||
thinkingBudgetHint: 'Automatically set budget to 32000 and retry when upstream returns budget_tokens constraint error (≥1024)',
|
||||
apikeySignature: 'API Key Signature Rectifier',
|
||||
apikeySignatureHint:
|
||||
'Automatically strip signatures and retry when API Key accounts receive signature-related errors (built-in patterns always apply)',
|
||||
apikeySignatureHintPool:
|
||||
'Automatically replace bad signatures with pooled ones when API Key accounts receive signature-related errors (pass through original error when pool is empty)',
|
||||
apikeyPatterns: 'Custom Match Patterns',
|
||||
apikeyPatternsHint:
|
||||
'Additional keywords matched against the response body (case-insensitive). Built-in patterns always apply; use these for supplementary matching.',
|
||||
apikeyPatternPlaceholder: 'e.g., thinking_error',
|
||||
addPattern: 'Add Pattern',
|
||||
poolSize: 'Signature Pool Size',
|
||||
poolSizeHint:
|
||||
'0 = pool disabled (legacy "strip and retry" behavior); >0 = harvest thinking signatures from successful responses into a Redis pool, then replace bad signatures with pooled ones on retry. OAuth/Setup accounts share one pool; each API Key account has its own. Signatures have a soft TTL of 1 hour; oldest entries are evicted when the pool is full.',
|
||||
poolSizeUnit: 'entries',
|
||||
saved: 'Rectifier settings saved',
|
||||
saveFailed: 'Failed to save rectifier settings'
|
||||
},
|
||||
|
||||
@@ -4934,16 +4934,24 @@ export default {
|
||||
enabledHint: '总开关,关闭后所有整流功能均不生效',
|
||||
thinkingSignature: 'Thinking 签名整流',
|
||||
thinkingSignatureHint: '当上游返回 thinking block 签名校验错误时,自动去除签名并重试',
|
||||
thinkingSignatureHintPool:
|
||||
'当上游返回 thinking block 签名校验错误时,自动使用签名池中的签名(池空直接透传错误)',
|
||||
thinkingBudget: 'Thinking Budget 整流',
|
||||
thinkingBudgetHint: '当上游返回 budget_tokens 约束错误(≥1024)时,自动将 budget 设为 32000 并重试',
|
||||
apikeySignature: 'API Key 签名整流',
|
||||
apikeySignatureHint:
|
||||
'当 API Key 账号的上游返回签名相关错误时,自动去除签名并重试(内置规则始终生效)',
|
||||
apikeySignatureHintPool:
|
||||
'当 API Key 账号的上游返回签名相关错误时,自动使用签名池中的签名替换(池空直接透传错误)',
|
||||
apikeyPatterns: '自定义匹配关键词',
|
||||
apikeyPatternsHint:
|
||||
'额外的关键词,匹配响应体中的内容(不区分大小写)。内置规则始终生效,此处用于补充额外匹配。',
|
||||
apikeyPatternPlaceholder: '例如:thinking_error 或 签名无效',
|
||||
addPattern: '添加关键词',
|
||||
poolSize: '签名池大小',
|
||||
poolSizeHint:
|
||||
'0 = 关闭池化(沿用"剥除 thinking 重试");>0 = 从成功响应抓取 thinking 签名到 Redis 池,签名错误时从池中取签名替换请求后重试。OAuth/Setup 账号共享一个池,每个 API Key 账号独立一个池。签名软 TTL 1 小时,池满后按时间淘汰最老的。',
|
||||
poolSizeUnit: '条',
|
||||
saved: '整流器设置保存成功',
|
||||
saveFailed: '保存整流器设置失败'
|
||||
},
|
||||
|
||||
@@ -429,6 +429,32 @@
|
||||
v-if="rectifierForm.enabled"
|
||||
class="space-y-4 border-t border-gray-100 pt-4 dark:border-dark-700"
|
||||
>
|
||||
<!-- Signature Pool Size -->
|
||||
<div>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div class="flex-1">
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">{{
|
||||
t('admin.settings.rectifier.poolSize')
|
||||
}}</label>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.settings.rectifier.poolSizeHint') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
v-model.number="rectifierForm.signature_pool_size"
|
||||
type="number"
|
||||
min="0"
|
||||
max="1000"
|
||||
class="input input-sm w-24"
|
||||
/>
|
||||
<span class="text-xs text-gray-500 dark:text-gray-400">{{
|
||||
t('admin.settings.rectifier.poolSizeUnit')
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Thinking Signature Rectifier -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
@@ -436,7 +462,11 @@
|
||||
t('admin.settings.rectifier.thinkingSignature')
|
||||
}}</label>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.settings.rectifier.thinkingSignatureHint') }}
|
||||
{{
|
||||
rectifierForm.signature_pool_size > 0
|
||||
? t('admin.settings.rectifier.thinkingSignatureHintPool')
|
||||
: t('admin.settings.rectifier.thinkingSignatureHint')
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<Toggle v-model="rectifierForm.thinking_signature_enabled" />
|
||||
@@ -462,7 +492,11 @@
|
||||
t('admin.settings.rectifier.apikeySignature')
|
||||
}}</label>
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.settings.rectifier.apikeySignatureHint') }}
|
||||
{{
|
||||
rectifierForm.signature_pool_size > 0
|
||||
? t('admin.settings.rectifier.apikeySignatureHintPool')
|
||||
: t('admin.settings.rectifier.apikeySignatureHint')
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<Toggle v-model="rectifierForm.apikey_signature_enabled" />
|
||||
@@ -2923,7 +2957,8 @@ const rectifierForm = reactive({
|
||||
thinking_signature_enabled: true,
|
||||
thinking_budget_enabled: true,
|
||||
apikey_signature_enabled: false,
|
||||
apikey_signature_patterns: [] as string[]
|
||||
apikey_signature_patterns: [] as string[],
|
||||
signature_pool_size: 0
|
||||
})
|
||||
|
||||
// Beta Policy 状态
|
||||
@@ -3893,7 +3928,8 @@ async function saveRectifierSettings() {
|
||||
apikey_signature_enabled: rectifierForm.apikey_signature_enabled,
|
||||
apikey_signature_patterns: rectifierForm.apikey_signature_patterns.filter(
|
||||
(p) => p.trim() !== ''
|
||||
)
|
||||
),
|
||||
signature_pool_size: rectifierForm.signature_pool_size
|
||||
})
|
||||
Object.assign(rectifierForm, updated)
|
||||
if (!Array.isArray(rectifierForm.apikey_signature_patterns)) {
|
||||
|
||||
Reference in New Issue
Block a user