From 7f4056abc963cee7614fdd87a424b944169dbac7 Mon Sep 17 00:00:00 2001 From: RedwindA Date: Thu, 7 Aug 2025 21:58:15 +0800 Subject: [PATCH] feat: optimize channel retrieval by respecting original model names --- model/channel_cache.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/model/channel_cache.go b/model/channel_cache.go index 90bd2ad1..86866e40 100644 --- a/model/channel_cache.go +++ b/model/channel_cache.go @@ -129,8 +129,6 @@ func CacheGetRandomSatisfiedChannel(c *gin.Context, group string, model string, } func getRandomSatisfiedChannel(group string, model string, retry int) (*Channel, error) { - model = ratio_setting.FormatMatchingModelName(model) - // if memory cache is disabled, get channel directly from database if !common.MemoryCacheEnabled { return GetRandomSatisfiedChannel(group, model, retry) @@ -138,8 +136,16 @@ func getRandomSatisfiedChannel(group string, model string, retry int) (*Channel, channelSyncLock.RLock() defer channelSyncLock.RUnlock() + + // First, try to find channels with the exact model name. channels := group2model2channels[group][model] + // If no channels found, try to find channels with the normalized model name. + if len(channels) == 0 { + normalizedModel := ratio_setting.FormatMatchingModelName(model) + channels = group2model2channels[group][normalizedModel] + } + if len(channels) == 0 { return nil, nil }