mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
Implement generic pool member scoring and probing
This commit is contained in:
@@ -192,6 +192,66 @@ export interface PoolKeysPageResponse {
|
||||
keys: PoolKeyDetail[]
|
||||
}
|
||||
|
||||
export type PoolScoreHardState =
|
||||
| 'available'
|
||||
| 'unknown'
|
||||
| 'cooldown'
|
||||
| 'quota_exhausted'
|
||||
| 'auth_invalid'
|
||||
| 'banned'
|
||||
| 'inactive'
|
||||
|
||||
export type PoolScoreProbeStatus = 'never' | 'ok' | 'failed' | 'stale' | 'in_progress'
|
||||
|
||||
export interface PoolScoreKeySummary {
|
||||
id: string
|
||||
name: string
|
||||
auth_type: string
|
||||
is_active: boolean
|
||||
internal_priority: number
|
||||
last_used_at: number | null
|
||||
}
|
||||
|
||||
export interface PoolMemberScoreItem {
|
||||
id: string
|
||||
pool_kind: string
|
||||
pool_id: string
|
||||
member_kind: string
|
||||
member_id: string
|
||||
capability: string
|
||||
scope_kind: string
|
||||
scope_id: string | null
|
||||
score: number
|
||||
hard_state: PoolScoreHardState
|
||||
score_version: number
|
||||
score_reason: Record<string, unknown> | null
|
||||
last_ranked_at: number | null
|
||||
last_scheduled_at: number | null
|
||||
last_success_at: number | null
|
||||
last_failure_at: number | null
|
||||
failure_count: number
|
||||
last_probe_attempt_at: number | null
|
||||
last_probe_success_at: number | null
|
||||
last_probe_failure_at: number | null
|
||||
probe_failure_count: number
|
||||
probe_status: PoolScoreProbeStatus
|
||||
updated_at: number
|
||||
key?: PoolScoreKeySummary | null
|
||||
}
|
||||
|
||||
export interface PoolScoresResponse {
|
||||
provider_id: string
|
||||
page: number
|
||||
page_size: number
|
||||
filters: {
|
||||
api_format?: string | null
|
||||
model_id?: string | null
|
||||
hard_state?: string | null
|
||||
probe_status?: string | null
|
||||
}
|
||||
items: PoolMemberScoreItem[]
|
||||
}
|
||||
|
||||
export interface PoolKeysQuery {
|
||||
page?: number
|
||||
page_size?: number
|
||||
@@ -203,6 +263,15 @@ export interface PoolKeysQuery {
|
||||
sort_order?: 'asc' | 'desc'
|
||||
}
|
||||
|
||||
export interface PoolScoresQuery {
|
||||
page?: number
|
||||
page_size?: number
|
||||
api_format?: string
|
||||
model_id?: string
|
||||
hard_state?: string
|
||||
probe_status?: string
|
||||
}
|
||||
|
||||
export interface PoolKeySelectionRequest {
|
||||
search?: string
|
||||
quick_selectors?: string[]
|
||||
@@ -293,6 +362,29 @@ export async function listPoolKeys(
|
||||
)
|
||||
}
|
||||
|
||||
export async function listPoolScores(
|
||||
providerId: string,
|
||||
params: PoolScoresQuery = {},
|
||||
options: PoolReadOptions = {},
|
||||
): Promise<PoolScoresResponse> {
|
||||
const normalizedParams = { ...params }
|
||||
const cacheKey = buildCacheKey(
|
||||
`pool:scores:${providerId}`,
|
||||
normalizedParams as Record<string, unknown>,
|
||||
)
|
||||
return cachedRequest(
|
||||
cacheKey,
|
||||
async () => {
|
||||
const response = await client.get<PoolScoresResponse>(
|
||||
`/api/admin/pool/${providerId}/scores`,
|
||||
{ params: normalizedParams },
|
||||
)
|
||||
return response.data
|
||||
},
|
||||
options.cacheTtlMs ?? 0,
|
||||
)
|
||||
}
|
||||
|
||||
export async function resolvePoolKeySelection(
|
||||
providerId: string,
|
||||
body: PoolKeySelectionRequest,
|
||||
|
||||
@@ -548,6 +548,9 @@ export interface PoolAdvancedConfig {
|
||||
health_policy_enabled?: boolean
|
||||
unschedulable_rules?: Array<Record<string, unknown>> | null
|
||||
batch_concurrency?: number | null
|
||||
probe_concurrency?: number | null
|
||||
score_top_n?: number | null
|
||||
score_fallback_scan_limit?: number | null
|
||||
probing_enabled?: boolean
|
||||
probing_interval_minutes?: number | null
|
||||
auto_remove_banned_keys?: boolean
|
||||
|
||||
Reference in New Issue
Block a user