feat(admin): expose Grok client tool cache opt-in

This commit is contained in:
superman2003 committed 2026-07-19 14:42:06 +08:00
1 parent 752b2eaa9b
commit 9d79b42729
4 files changed
+106 -2

No files matched your search

@@ -428,6 +428,26 @@
</div>
<!-- Grok OAuth client-tool prompt cache opt-in -->
<div
v-if="account.platform === 'grok' && account.type === 'oauth'"
class="border-t border-gray-200 pt-4 dark:border-dark-600"
>
<div class="flex items-center justify-between gap-4">
<div class="min-w-0">
<label class="input-label mb-0">{{ t('admin.accounts.grokClientToolCache.title') }}</label>
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
{{ t('admin.accounts.grokClientToolCache.hint') }}
</p>
</div>
<Toggle
v-model="grokClientToolCacheEnabled"
data-testid="grok-client-tool-cache-toggle"
:aria-label="t('admin.accounts.grokClientToolCache.title')"
/>
</div>
</div>
<!-- Grok OAuth Custom Upstream URL (仅改写转发端点,OAuth 授权/刷新不受影响) -->
<div
v-if="account.platform === 'grok' && account.type === 'oauth'"
@@ -2699,6 +2719,7 @@ const allowedModels = ref<string[]>([])
const DEFAULT_POOL_MODE_RETRY_COUNT = 3
const MAX_POOL_MODE_RETRY_COUNT = 10
const DEFAULT_POOL_MODE_RETRY_STATUS_CODES = [401, 403, 429]
const GROK_CLIENT_TOOL_CACHE_EXTRA_KEY = 'grok_client_tool_cache_enabled'
const poolModeEnabled = ref(false)
const poolModeRetryCount = ref(DEFAULT_POOL_MODE_RETRY_COUNT)
const poolModeRetryStatusCodesInput = ref('')
@@ -2747,6 +2768,7 @@ const headerOverrideCapable = computed(
// Grok OAuth 自定义上游地址(仅转发端点;OAuth 授权/令牌刷新不受影响)
const grokOAuthCustomBaseUrlEnabled = ref(false)
const grokOAuthBaseUrl = ref('')
const grokClientToolCacheEnabled = ref(false)
const interceptWarmupRequests = ref(false)
const autoPauseOnExpired = ref(false)
@@ -3402,6 +3424,10 @@ const syncFormFromAccount = (newAccount: Account | null) => {
// Load Grok OAuth custom upstream URL state(存储的官方地址视同未定制)
grokOAuthCustomBaseUrlEnabled.value = false
grokOAuthBaseUrl.value = ''
grokClientToolCacheEnabled.value =
newAccount.platform === 'grok' &&
newAccount.type === 'oauth' &&
newAccount.extra?.[GROK_CLIENT_TOOL_CACHE_EXTRA_KEY] === true
if (newAccount.platform === 'grok' && newAccount.type === 'oauth' && newAccount.credentials) {
const grokCreds = newAccount.credentials as Record<string, unknown>
if (isCustomGrokBaseUrl(grokCreds.base_url)) {
@@ -4288,6 +4314,16 @@ const handleSubmit = async () => {
applyHeaderOverride(newCredentials, headerOverrideEnabled.value, headerOverrideRows.value, 'edit')
updatePayload.credentials = newCredentials
const newExtra: Record<string, unknown> = {
...((props.account.extra as Record<string, unknown>) || {})
}
if (grokClientToolCacheEnabled.value) {
newExtra[GROK_CLIENT_TOOL_CACHE_EXTRA_KEY] = true
} else {
delete newExtra[GROK_CLIENT_TOOL_CACHE_EXTRA_KEY]
}
updatePayload.extra = newExtra
}
// OpenAI: 手动覆盖订阅档位 plan_type(Plus/Pro/Free)。仅 OAuth 非影子账号: