Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
037cc473
authored
Aug 07, 2025
by
RedwindA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: optimize channel retrieval by respecting original model names
parent
87cfcf11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
model/channel_cache.go
+8
-2
No files found.
model/channel_cache.go
View file @
037cc473
...
...
@@ -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
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment