mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
refactor: 废弃 rate_multiplier 字段,改进成本倍率回退逻辑
- 在前后端模型中为 rate_multiplier 添加 @deprecated 标记 - 修复 rate_multipliers 回退逻辑:当 rate_multipliers 存在但未配置当前格式时使用 1.0 - ModelMappingsTab: 删除映射后自动保存,简化空状态提示 - ModelManagement: 添加 refreshModel 事件在映射更新后刷新模型数据 - CacheAwareScheduler: 添加映射匹配调试日志,移除 candidate_models 限制
This commit is contained in:
@@ -499,6 +499,7 @@ const emit = defineEmits<{
|
||||
'editProvider': [provider: any]
|
||||
'deleteProvider': [provider: any]
|
||||
'toggleProviderStatus': [provider: any]
|
||||
'refreshModel': []
|
||||
}>()
|
||||
const { success: showSuccess, error: showError } = useToast()
|
||||
const { copyToClipboard } = useClipboard()
|
||||
@@ -548,6 +549,8 @@ function handleMappingsUpdate(_mappings: string[]) {
|
||||
// 映射已在 ModelMappingsTab 内部保存到服务器
|
||||
// 刷新路由数据以反映可能的候选变化
|
||||
refreshRoutingData()
|
||||
// 通知父组件刷新模型数据
|
||||
emit('refreshModel')
|
||||
}
|
||||
|
||||
// 暴露刷新方法给父组件
|
||||
|
||||
@@ -155,15 +155,12 @@
|
||||
<!-- 空状态 -->
|
||||
<div
|
||||
v-else
|
||||
class="text-center py-8"
|
||||
class="text-center py-32"
|
||||
>
|
||||
<GitMerge class="w-10 h-10 mx-auto text-muted-foreground/30 mb-3" />
|
||||
<p class="text-sm text-muted-foreground">
|
||||
暂无映射规则
|
||||
</p>
|
||||
<p class="text-xs text-muted-foreground mt-1">
|
||||
添加映射可匹配 Provider Key 白名单中的模型
|
||||
</p>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -462,14 +459,15 @@ function addMapping() {
|
||||
expandedIndex.value = localMappings.value.length - 1
|
||||
}
|
||||
|
||||
function removeMapping(index: number) {
|
||||
async function removeMapping(index: number) {
|
||||
localMappings.value.splice(index, 1)
|
||||
isDirty.value = true
|
||||
if (expandedIndex.value === index) {
|
||||
expandedIndex.value = null
|
||||
} else if (expandedIndex.value !== null && expandedIndex.value > index) {
|
||||
expandedIndex.value--
|
||||
}
|
||||
// 删除后自动保存
|
||||
await saveMappings()
|
||||
}
|
||||
|
||||
async function saveMappings() {
|
||||
|
||||
@@ -1423,6 +1423,11 @@ function getKeyRateMultiplier(key: EndpointAPIKey, format: string): number {
|
||||
if (key.rate_multipliers && key.rate_multipliers[format] !== undefined) {
|
||||
return key.rate_multipliers[format]
|
||||
}
|
||||
// 如果 rate_multipliers 存在但该格式未配置,说明用户期望使用默认值 1.0
|
||||
// 只有当 rate_multipliers 完全不存在时,才回退到 rate_multiplier
|
||||
if (key.rate_multipliers && Object.keys(key.rate_multipliers).length > 0) {
|
||||
return 1.0
|
||||
}
|
||||
// 回退到默认倍率
|
||||
return key.rate_multiplier || 1.0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user