feat: add adaptive pool metrics and self-check

This commit is contained in:
fawney19
2026-05-15 02:21:11 +08:00
parent bf511f9f8c
commit 54a8312e46
34 changed files with 4521 additions and 300 deletions
@@ -3,7 +3,7 @@
<!-- Header -->
<div class="p-4 border-b border-border/60">
<div class="flex items-center justify-between">
<div class="flex items-center gap-2">
<div class="flex flex-wrap items-center gap-2">
<h3 class="text-sm font-semibold">
号池状态
</h3>
@@ -21,6 +21,34 @@
>
{{ poolStatus.total_sticky_sessions }} 个粘性会话
</Badge>
<Badge
v-if="poolStatus && poolStatus.provider_desired_hot > 0"
variant="outline"
class="text-xs"
>
热池 {{ poolStatus.provider_hot_count }} / {{ poolStatus.provider_desired_hot }}
</Badge>
<Badge
v-if="poolStatus && poolStatus.provider_in_flight > 0"
variant="outline"
class="text-xs"
>
in-flight {{ poolStatus.provider_in_flight }}
</Badge>
<Badge
v-if="poolStatus && poolStatus.provider_desired_hot > 0"
variant="outline"
class="text-xs"
>
EMA {{ formatEmaHeat(poolStatus.provider_ema_in_flight) }}
</Badge>
<Badge
v-if="poolStatus?.provider_burst_pending"
variant="secondary"
class="text-xs"
>
补热中
</Badge>
</div>
<RefreshButton
:loading="refreshing"
@@ -265,6 +293,11 @@ function formatTokens(tokens: number): string {
return String(tokens)
}
function formatEmaHeat(value: number): string {
if (!Number.isFinite(value) || value <= 0) return '0.0'
return value.toFixed(1)
}
function getCostBarColor(usage: number, limit: number): string {
const ratio = usage / limit
if (ratio >= 0.9) return 'bg-red-500'