mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 10:57:03 +08:00
feat(routing): consolidate scheduling strategy configuration
This commit is contained in:
@@ -24,14 +24,12 @@
|
||||
:api-format-filters="apiFormatFilters"
|
||||
:model-filters="modelFilters"
|
||||
:has-active-filters="hasActiveFilters"
|
||||
:priority-mode-label="priorityModeConfig.label"
|
||||
:loading="loading"
|
||||
@update:search-query="searchQuery = $event"
|
||||
@update:filter-status="filterStatus = $event"
|
||||
@update:filter-api-format="filterApiFormat = $event"
|
||||
@update:filter-model="filterModel = $event"
|
||||
@reset-filters="resetFilters"
|
||||
@open-priority-dialog="openPriorityDialog"
|
||||
@batch-process="openProviderBatchDialog"
|
||||
@add-provider="openAddProviderDialog"
|
||||
@refresh="loadProviders"
|
||||
@@ -215,11 +213,6 @@
|
||||
@changed="handleProviderBatchChanged"
|
||||
/>
|
||||
|
||||
<PriorityManagementDialog
|
||||
v-model="priorityDialogOpen"
|
||||
@saved="handlePrioritySaved"
|
||||
/>
|
||||
|
||||
<ProviderDetailDrawer
|
||||
v-if="providerDrawerMounted"
|
||||
:open="providerDrawerOpen"
|
||||
@@ -250,7 +243,7 @@ import TableHead from '@/components/ui/table-head.vue'
|
||||
import SortableTableHead from '@/components/ui/sortable-table-head.vue'
|
||||
import TableFilterMenu from '@/components/ui/table-filter-menu.vue'
|
||||
import Pagination from '@/components/ui/pagination.vue'
|
||||
import { ProviderFormDialog, PriorityManagementDialog, ProviderAuthDialog } from '@/features/providers/components'
|
||||
import { ProviderFormDialog, ProviderAuthDialog } from '@/features/providers/components'
|
||||
import ProviderBatchActionDialog from '@/features/providers/components/ProviderBatchActionDialog.vue'
|
||||
import ProviderTableHeader from '@/features/providers/components/ProviderTableHeader.vue'
|
||||
import ProviderTableRow from '@/features/providers/components/ProviderTableRow.vue'
|
||||
@@ -271,9 +264,6 @@ import {
|
||||
getGlobalModels,
|
||||
type ProviderWithEndpointsSummary,
|
||||
} from '@/api/endpoints'
|
||||
import { adminApi } from '@/api/admin'
|
||||
import { listRoutingGroups } from '@/api/routing-profiles'
|
||||
import { normalizeRoutingGroupConfig } from '@/features/routing/utils/routingPolicy'
|
||||
import { parseApiError } from '@/utils/errorParser'
|
||||
import { useI18n } from '@/i18n'
|
||||
|
||||
@@ -309,8 +299,6 @@ let providersRequestId = 0
|
||||
const providerDialogOpen = ref(false)
|
||||
const providerBatchDialogOpen = ref(false)
|
||||
const providerToEdit = ref<ProviderWithEndpointsSummary | null>(null)
|
||||
const priorityDialogOpen = ref(false)
|
||||
const priorityMode = ref<'provider' | 'global_key'>('provider')
|
||||
const providerDrawerOpen = ref(false)
|
||||
const providerDrawerMounted = ref(false)
|
||||
const selectedProviderId = ref<string | null>(null)
|
||||
@@ -325,7 +313,6 @@ const DELETE_POLL_INTERVAL_MS = 2000
|
||||
const DELETE_POLL_MAX_MS = 30 * 60 * 1000
|
||||
const DELETE_POLL_MAX_FAILURES = 3
|
||||
const PROVIDER_SUMMARY_CACHE_TTL_MS = 10 * 1000
|
||||
const PROVIDER_PRIORITY_MODE_CACHE_TTL_MS = 30 * 1000
|
||||
const PROVIDER_MODEL_FILTER_CACHE_TTL_MS = 10 * 1000
|
||||
|
||||
async function pollProviderDeleteTask(providerId: string, taskId: string) {
|
||||
@@ -519,13 +506,6 @@ async function saveDescription(_event: Event, provider: ProviderWithEndpointsSum
|
||||
}
|
||||
}
|
||||
|
||||
// 优先级模式配置
|
||||
const priorityModeConfig = computed(() => {
|
||||
return {
|
||||
label: legacyT(priorityMode.value === 'global_key' ? '全局 Key 优先' : '提供商优先'),
|
||||
}
|
||||
})
|
||||
|
||||
// 当前已有提供商的最大优先级
|
||||
const maxProviderPriority = computed(() => {
|
||||
if (providers.value.length === 0) return undefined
|
||||
@@ -535,30 +515,6 @@ const maxProviderPriority = computed(() => {
|
||||
return priorities.length > 0 ? Math.max(...priorities) : undefined
|
||||
})
|
||||
|
||||
// 加载优先级模式:优先使用启用中的系统默认调度策略,旧的系统配置键仅作兜底
|
||||
async function loadPriorityMode(options: { cacheTtlMs?: number } = {}) {
|
||||
try {
|
||||
const groups = await listRoutingGroups()
|
||||
const systemDefault = groups.items.find(group => group.is_system_default && group.enabled)
|
||||
if (systemDefault) {
|
||||
priorityMode.value = normalizeRoutingGroupConfig(systemDefault.config_json).default_policy.priority_mode
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
// 路由策略不可用时继续尝试旧配置
|
||||
}
|
||||
try {
|
||||
const response = await adminApi.getSystemConfig('provider_priority_mode', {
|
||||
cacheTtlMs: options.cacheTtlMs ?? 0,
|
||||
})
|
||||
if (response.value) {
|
||||
priorityMode.value = response.value as 'provider' | 'global_key'
|
||||
}
|
||||
} catch {
|
||||
priorityMode.value = 'provider'
|
||||
}
|
||||
}
|
||||
|
||||
// 加载全局模型列表(用于模型筛选下拉)
|
||||
async function loadGlobalModelList(options: { cacheTtlMs?: number } = {}) {
|
||||
try {
|
||||
@@ -636,11 +592,6 @@ function openAddProviderDialog() {
|
||||
providerDialogOpen.value = true
|
||||
}
|
||||
|
||||
// 打开优先级管理对话框
|
||||
function openPriorityDialog() {
|
||||
priorityDialogOpen.value = true
|
||||
}
|
||||
|
||||
function openProviderBatchDialog() {
|
||||
providerBatchDialogOpen.value = true
|
||||
}
|
||||
@@ -709,12 +660,6 @@ async function handleDrawerRefresh() {
|
||||
await refreshProviderSnapshot(selectedProviderId.value)
|
||||
}
|
||||
|
||||
// 优先级保存成功回调
|
||||
async function handlePrioritySaved() {
|
||||
await loadProviders()
|
||||
await loadPriorityMode()
|
||||
}
|
||||
|
||||
// 处理提供商添加
|
||||
function handleProviderAdded() {
|
||||
void loadProviders()
|
||||
@@ -791,7 +736,6 @@ function handleGlobalClick(event: MouseEvent) {
|
||||
|
||||
onMounted(() => {
|
||||
void loadProviders({ cacheTtlMs: PROVIDER_SUMMARY_CACHE_TTL_MS })
|
||||
void loadPriorityMode({ cacheTtlMs: PROVIDER_PRIORITY_MODE_CACHE_TTL_MS })
|
||||
void loadGlobalModelList({ cacheTtlMs: PROVIDER_MODEL_FILTER_CACHE_TTL_MS })
|
||||
void loadArchitectureSchemas()
|
||||
document.addEventListener('click', handleGlobalClick, true)
|
||||
|
||||
Reference in New Issue
Block a user