mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
feat(kiro): add simulated cache provider toggle
This commit is contained in:
@@ -132,6 +132,12 @@ pub(crate) fn build_admin_provider_summary_value(
|
|||||||
.and_then(|cfg| cfg.get("architecture_id"))
|
.and_then(|cfg| cfg.get("architecture_id"))
|
||||||
.and_then(serde_json::Value::as_str)
|
.and_then(serde_json::Value::as_str)
|
||||||
.map(ToOwned::to_owned);
|
.map(ToOwned::to_owned);
|
||||||
|
let kiro_simulated_cache_enabled = config
|
||||||
|
.and_then(|cfg| cfg.get("kiro"))
|
||||||
|
.and_then(serde_json::Value::as_object)
|
||||||
|
.and_then(|cfg| cfg.get("simulated_cache_enabled"))
|
||||||
|
.and_then(serde_json::Value::as_bool)
|
||||||
|
.unwrap_or(false);
|
||||||
let billing_type = quota_snapshot
|
let billing_type = quota_snapshot
|
||||||
.map(|quota| quota.billing_type.clone())
|
.map(|quota| quota.billing_type.clone())
|
||||||
.or_else(|| provider.billing_type.clone());
|
.or_else(|| provider.billing_type.clone());
|
||||||
@@ -190,6 +196,7 @@ pub(crate) fn build_admin_provider_summary_value(
|
|||||||
"endpoint_health_details": endpoint_health_details,
|
"endpoint_health_details": endpoint_health_details,
|
||||||
"ops_configured": ops_configured,
|
"ops_configured": ops_configured,
|
||||||
"ops_architecture_id": ops_architecture_id,
|
"ops_architecture_id": ops_architecture_id,
|
||||||
|
"kiro_simulated_cache_enabled": kiro_simulated_cache_enabled,
|
||||||
"created_at": endpoint_timestamp_or_now(provider.created_at_unix_ms, now_unix_secs),
|
"created_at": endpoint_timestamp_or_now(provider.created_at_unix_ms, now_unix_secs),
|
||||||
"updated_at": endpoint_timestamp_or_now(provider.updated_at_unix_secs, now_unix_secs),
|
"updated_at": endpoint_timestamp_or_now(provider.updated_at_unix_secs, now_unix_secs),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ async fn gateway_handles_admin_provider_summary_locally_with_trusted_admin_princ
|
|||||||
"pool_advanced": {"enabled": true},
|
"pool_advanced": {"enabled": true},
|
||||||
"failover_rules": {"strategy": "ordered"},
|
"failover_rules": {"strategy": "ordered"},
|
||||||
"chat_pii_redaction": {"enabled": true},
|
"chat_pii_redaction": {"enabled": true},
|
||||||
|
"kiro": {"simulated_cache_enabled": true},
|
||||||
"provider_ops": {"architecture_id": "anyrouter"}
|
"provider_ops": {"architecture_id": "anyrouter"}
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
@@ -353,6 +354,7 @@ async fn gateway_handles_admin_provider_summary_locally_with_trusted_admin_princ
|
|||||||
assert_eq!(payload["ops_configured"], true);
|
assert_eq!(payload["ops_configured"], true);
|
||||||
assert_eq!(payload["ops_architecture_id"], "anyrouter");
|
assert_eq!(payload["ops_architecture_id"], "anyrouter");
|
||||||
assert_eq!(payload["chat_pii_redaction"], json!({"enabled": true}));
|
assert_eq!(payload["chat_pii_redaction"], json!({"enabled": true}));
|
||||||
|
assert_eq!(payload["kiro_simulated_cache_enabled"], true);
|
||||||
assert_eq!(payload["created_at"], "2024-03-21T05:46:40Z");
|
assert_eq!(payload["created_at"], "2024-03-21T05:46:40Z");
|
||||||
assert_eq!(payload["updated_at"], "2024-03-21T05:48:20Z");
|
assert_eq!(payload["updated_at"], "2024-03-21T05:48:20Z");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ function normalizeProviderSummary(
|
|||||||
...provider,
|
...provider,
|
||||||
chat_pii_redaction: normalizeChatPiiRedactionProvider(provider.chat_pii_redaction),
|
chat_pii_redaction: normalizeChatPiiRedactionProvider(provider.chat_pii_redaction),
|
||||||
pool_advanced: normalizePoolAdvanced(provider.pool_advanced),
|
pool_advanced: normalizePoolAdvanced(provider.pool_advanced),
|
||||||
|
kiro_simulated_cache_enabled: provider.kiro_simulated_cache_enabled ?? false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -675,6 +675,7 @@ export interface ProviderWithEndpointsSummary {
|
|||||||
failover_rules?: FailoverRulesConfig | null
|
failover_rules?: FailoverRulesConfig | null
|
||||||
ops_configured: boolean // 是否配置了扩展操作(余额监控等)
|
ops_configured: boolean // 是否配置了扩展操作(余额监控等)
|
||||||
ops_architecture_id?: string // 扩展操作使用的架构 ID(如 cubence, anyrouter)
|
ops_architecture_id?: string // 扩展操作使用的架构 ID(如 cubence, anyrouter)
|
||||||
|
kiro_simulated_cache_enabled?: boolean
|
||||||
created_at: string
|
created_at: string
|
||||||
updated_at: string
|
updated_at: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,6 +275,22 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="form.provider_type === 'kiro'"
|
||||||
|
class="flex items-center justify-between p-3 border rounded-lg bg-muted/50"
|
||||||
|
>
|
||||||
|
<div class="space-y-0.5">
|
||||||
|
<span class="text-sm font-medium">模拟缓存模式</span>
|
||||||
|
<p class="text-xs text-muted-foreground leading-relaxed">
|
||||||
|
启用后仅对 Kiro 请求模拟 prompt cache 读写计量。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
:model-value="form.kiro_simulated_cache_enabled"
|
||||||
|
@update:model-value="(v: boolean) => form.kiro_simulated_cache_enabled = v"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center justify-between gap-4 p-3 border rounded-lg bg-muted/50">
|
<div class="flex items-center justify-between gap-4 p-3 border rounded-lg bg-muted/50">
|
||||||
<div class="space-y-0.5">
|
<div class="space-y-0.5">
|
||||||
<span class="text-sm font-medium">敏感信息保护</span>
|
<span class="text-sm font-medium">敏感信息保护</span>
|
||||||
@@ -383,6 +399,8 @@ const form = ref({
|
|||||||
request_timeout: undefined as number | undefined,
|
request_timeout: undefined as number | undefined,
|
||||||
// 号池模式
|
// 号池模式
|
||||||
pool_mode_enabled: false,
|
pool_mode_enabled: false,
|
||||||
|
// Kiro 专属配置
|
||||||
|
kiro_simulated_cache_enabled: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
// 重置表单
|
// 重置表单
|
||||||
@@ -409,6 +427,8 @@ function resetForm() {
|
|||||||
request_timeout: undefined,
|
request_timeout: undefined,
|
||||||
// 号池模式
|
// 号池模式
|
||||||
pool_mode_enabled: false,
|
pool_mode_enabled: false,
|
||||||
|
// Kiro 专属配置
|
||||||
|
kiro_simulated_cache_enabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,6 +459,8 @@ function loadProviderData() {
|
|||||||
request_timeout: props.provider.request_timeout ?? undefined,
|
request_timeout: props.provider.request_timeout ?? undefined,
|
||||||
// 号池模式
|
// 号池模式
|
||||||
pool_mode_enabled: poolAdvanced !== null,
|
pool_mode_enabled: poolAdvanced !== null,
|
||||||
|
// Kiro 专属配置
|
||||||
|
kiro_simulated_cache_enabled: props.provider.kiro_simulated_cache_enabled ?? false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,6 +479,9 @@ watch(() => form.value.provider_type, () => {
|
|||||||
if (!isEditMode.value) {
|
if (!isEditMode.value) {
|
||||||
form.value.pool_mode_enabled = false
|
form.value.pool_mode_enabled = false
|
||||||
}
|
}
|
||||||
|
if (form.value.provider_type !== 'kiro') {
|
||||||
|
form.value.kiro_simulated_cache_enabled = false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 提交表单
|
// 提交表单
|
||||||
@@ -506,6 +531,15 @@ const handleSubmit = async () => {
|
|||||||
pool_advanced: form.value.pool_mode_enabled
|
pool_advanced: form.value.pool_mode_enabled
|
||||||
? (currentPoolAdvanced ?? {})
|
? (currentPoolAdvanced ?? {})
|
||||||
: null,
|
: null,
|
||||||
|
...(form.value.provider_type === 'kiro'
|
||||||
|
? {
|
||||||
|
config: {
|
||||||
|
kiro: {
|
||||||
|
simulated_cache_enabled: form.value.kiro_simulated_cache_enabled,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEditMode.value && props.provider) {
|
if (isEditMode.value && props.provider) {
|
||||||
|
|||||||
Reference in New Issue
Block a user