mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 03:09:50 +08:00
Merge remote-tracking branch 'upstream/main'
# Conflicts: # apps/aether-gateway/src/handlers/admin/provider/endpoints_admin/payloads.rs # apps/aether-gateway/src/handlers/admin/provider/endpoints_admin/reads.rs # apps/aether-gateway/src/handlers/admin/provider/endpoints_admin/update.rs # apps/aether-gateway/src/tests/control/admin/endpoints/routes.rs # frontend/src/features/models/components/GlobalModelFormDialog.vue # frontend/src/features/providers/components/ProviderModelFormDialog.vue # frontend/src/features/providers/components/provider-tabs/__tests__/model-test-request.spec.ts # frontend/src/features/providers/components/provider-tabs/model-test-request.ts
This commit is contained in:
@@ -374,6 +374,7 @@ import {
|
||||
isModelTestableEndpoint,
|
||||
parseModelTestRequestHeadersDraft,
|
||||
parseModelTestRequestBodyDraft,
|
||||
selectPreferredModelTestEndpoint,
|
||||
syncModelTestRequestBodyDraft,
|
||||
} from './model-test-request'
|
||||
|
||||
@@ -428,6 +429,7 @@ const deletingGroup = ref<AliasGroup | null>(null)
|
||||
const testingMapping = ref<string | null>(null)
|
||||
const pendingMappingKey = ref<string | null>(null)
|
||||
const testingModelName = ref<string | null>(null)
|
||||
const testingSourceModel = ref<Model | null>(null)
|
||||
const preselectedModelId = ref<string | null>(null)
|
||||
const selectedTestEndpoint = ref<ProviderEndpoint | null>(null)
|
||||
const testRequestHeadersDraft = ref('')
|
||||
@@ -716,6 +718,7 @@ function handleTestDialogClose() {
|
||||
modelTest.resetState()
|
||||
pendingMappingKey.value = null
|
||||
testingModelName.value = null
|
||||
testingSourceModel.value = null
|
||||
testingMapping.value = null
|
||||
selectedTestEndpoint.value = null
|
||||
mappingTestEndpoints.value = null
|
||||
@@ -738,8 +741,25 @@ function handleSelectTestEndpoint(endpointId: string) {
|
||||
syncMappingTestRequestBody()
|
||||
}
|
||||
|
||||
function findMappingTestModel(modelName: string): Model | null {
|
||||
const normalized = modelName.trim()
|
||||
if (!normalized) return null
|
||||
|
||||
return models.value.find(model => (
|
||||
model.provider_model_name === normalized
|
||||
|| model.global_model_name === normalized
|
||||
|| model.global_model_display_name === normalized
|
||||
|| (model.provider_model_mappings ?? []).some(alias => alias.name === normalized)
|
||||
)) ?? null
|
||||
}
|
||||
|
||||
// 测试映射(直连测试,带故障转移和实时进度)
|
||||
function runMappingTest(testingKey: string, modelName: string, endpointsOverride?: ProviderEndpoint[]) {
|
||||
function runMappingTest(
|
||||
testingKey: string,
|
||||
modelName: string,
|
||||
endpointsOverride?: ProviderEndpoint[],
|
||||
sourceModel?: Model | null,
|
||||
) {
|
||||
const endpoints = endpointsOverride ?? activeEndpoints.value
|
||||
if (endpoints.length === 0) {
|
||||
showError('暂无可用于测试的活跃端点')
|
||||
@@ -750,8 +770,12 @@ function runMappingTest(testingKey: string, modelName: string, endpointsOverride
|
||||
modelTest.dialogOpen.value = true
|
||||
testingMapping.value = null
|
||||
testingModelName.value = modelName
|
||||
testingSourceModel.value = sourceModel ?? findMappingTestModel(modelName)
|
||||
mappingTestEndpoints.value = endpointsOverride ?? null
|
||||
selectedTestEndpoint.value = endpoints[0] ?? null
|
||||
selectedTestEndpoint.value = selectPreferredModelTestEndpoint(
|
||||
testingSourceModel.value,
|
||||
endpoints,
|
||||
)
|
||||
testRequestHeadersResetValue.value = buildDefaultModelTestRequestHeaders()
|
||||
testRequestHeadersDraft.value = testRequestHeadersResetValue.value
|
||||
resetMappingTestRequestBody()
|
||||
@@ -763,6 +787,7 @@ function resetMappingTestRequestBody() {
|
||||
testRequestBodyResetValue.value = buildDefaultModelTestRequestBody(
|
||||
testingModelName.value,
|
||||
selectedTestEndpoint.value?.api_format,
|
||||
testingSourceModel.value,
|
||||
)
|
||||
testRequestBodyDraft.value = testRequestBodyResetValue.value
|
||||
}
|
||||
@@ -773,6 +798,7 @@ function syncMappingTestRequestBody() {
|
||||
const nextResetValue = buildDefaultModelTestRequestBody(
|
||||
testingModelName.value,
|
||||
selectedTestEndpoint.value?.api_format,
|
||||
testingSourceModel.value,
|
||||
)
|
||||
const next = syncModelTestRequestBodyDraft(
|
||||
testRequestBodyDraft.value,
|
||||
@@ -840,7 +866,7 @@ function scopedMappingEndpoints(item: CombinedMapping): ProviderEndpoint[] {
|
||||
|
||||
// 测试精确映射
|
||||
function testMapping(item: CombinedMapping, mapping: MappingItem) {
|
||||
runMappingTest(`${item.key}-${mapping.name}`, mapping.name, scopedMappingEndpoints(item))
|
||||
runMappingTest(`${item.key}-${mapping.name}`, mapping.name, scopedMappingEndpoints(item), item.group?.model)
|
||||
}
|
||||
|
||||
// 测试正则映射
|
||||
|
||||
Reference in New Issue
Block a user