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
047d4471
authored
Aug 08, 2025
by
Calcium-Ion
Committed by
GitHub
Aug 08, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1523 from RedwindA/refactor/improve-modelName-wildcard
fix: 修复通配符处理对判断可用渠道的破坏
parents
85032b3e
037cc473
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
model/channel_cache.go
+8
-2
setting/ratio_setting/model_ratio.go
+10
-5
No files found.
model/channel_cache.go
View file @
047d4471
...
@@ -129,8 +129,6 @@ func CacheGetRandomSatisfiedChannel(c *gin.Context, group string, model string,
...
@@ -129,8 +129,6 @@ func CacheGetRandomSatisfiedChannel(c *gin.Context, group string, model string,
}
}
func
getRandomSatisfiedChannel
(
group
string
,
model
string
,
retry
int
)
(
*
Channel
,
error
)
{
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 memory cache is disabled, get channel directly from database
if
!
common
.
MemoryCacheEnabled
{
if
!
common
.
MemoryCacheEnabled
{
return
GetRandomSatisfiedChannel
(
group
,
model
,
retry
)
return
GetRandomSatisfiedChannel
(
group
,
model
,
retry
)
...
@@ -138,8 +136,16 @@ func getRandomSatisfiedChannel(group string, model string, retry int) (*Channel,
...
@@ -138,8 +136,16 @@ func getRandomSatisfiedChannel(group string, model string, retry int) (*Channel,
channelSyncLock
.
RLock
()
channelSyncLock
.
RLock
()
defer
channelSyncLock
.
RUnlock
()
defer
channelSyncLock
.
RUnlock
()
// First, try to find channels with the exact model name.
channels
:=
group2model2channels
[
group
][
model
]
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
{
if
len
(
channels
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
...
setting/ratio_setting/model_ratio.go
View file @
047d4471
...
@@ -150,6 +150,7 @@ var defaultModelRatio = map[string]float64{
...
@@ -150,6 +150,7 @@ var defaultModelRatio = map[string]float64{
"gemini-2.5-flash-preview-05-20-nothinking"
:
0.075
,
"gemini-2.5-flash-preview-05-20-nothinking"
:
0.075
,
"gemini-2.5-flash-thinking-*"
:
0.075
,
// 用于为后续所有2.5 flash thinking budget 模型设置默认倍率
"gemini-2.5-flash-thinking-*"
:
0.075
,
// 用于为后续所有2.5 flash thinking budget 模型设置默认倍率
"gemini-2.5-pro-thinking-*"
:
0.625
,
// 用于为后续所有2.5 pro thinking budget 模型设置默认倍率
"gemini-2.5-pro-thinking-*"
:
0.625
,
// 用于为后续所有2.5 pro thinking budget 模型设置默认倍率
"gemini-2.5-flash-lite-preview-thinking-*"
:
0.05
,
"gemini-2.5-flash-lite-preview-06-17"
:
0.05
,
"gemini-2.5-flash-lite-preview-06-17"
:
0.05
,
"gemini-2.5-flash"
:
0.15
,
"gemini-2.5-flash"
:
0.15
,
"text-embedding-004"
:
0.001
,
"text-embedding-004"
:
0.001
,
...
@@ -503,9 +504,6 @@ func getHardcodedCompletionModelRatio(name string) (float64, bool) {
...
@@ -503,9 +504,6 @@ func getHardcodedCompletionModelRatio(name string) (float64, bool) {
return
3.5
/
0.15
,
false
return
3.5
/
0.15
,
false
}
}
if
strings
.
HasPrefix
(
name
,
"gemini-2.5-flash-lite"
)
{
if
strings
.
HasPrefix
(
name
,
"gemini-2.5-flash-lite"
)
{
if
strings
.
HasPrefix
(
name
,
"gemini-2.5-flash-lite-preview"
)
{
return
4
,
false
}
return
4
,
false
return
4
,
false
}
}
return
2.5
/
0.3
,
true
return
2.5
/
0.3
,
true
...
@@ -657,8 +655,15 @@ func GetCompletionRatioCopy() map[string]float64 {
...
@@ -657,8 +655,15 @@ func GetCompletionRatioCopy() map[string]float64 {
// 转换模型名,减少渠道必须配置各种带参数模型
// 转换模型名,减少渠道必须配置各种带参数模型
func
FormatMatchingModelName
(
name
string
)
string
{
func
FormatMatchingModelName
(
name
string
)
string
{
name
=
handleThinkingBudgetModel
(
name
,
"gemini-2.5-flash"
,
"gemini-2.5-flash-thinking-*"
)
name
=
handleThinkingBudgetModel
(
name
,
"gemini-2.5-pro"
,
"gemini-2.5-pro-thinking-*"
)
if
strings
.
HasPrefix
(
name
,
"gemini-2.5-flash-lite"
)
{
name
=
handleThinkingBudgetModel
(
name
,
"gemini-2.5-flash-lite"
,
"gemini-2.5-flash-lite-thinking-*"
)
}
else
if
strings
.
HasPrefix
(
name
,
"gemini-2.5-flash"
)
{
name
=
handleThinkingBudgetModel
(
name
,
"gemini-2.5-flash"
,
"gemini-2.5-flash-thinking-*"
)
}
else
if
strings
.
HasPrefix
(
name
,
"gemini-2.5-pro"
)
{
name
=
handleThinkingBudgetModel
(
name
,
"gemini-2.5-pro"
,
"gemini-2.5-pro-thinking-*"
)
}
if
strings
.
HasPrefix
(
name
,
"gpt-4-gizmo"
)
{
if
strings
.
HasPrefix
(
name
,
"gpt-4-gizmo"
)
{
name
=
"gpt-4-gizmo-*"
name
=
"gpt-4-gizmo-*"
}
}
...
...
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