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
Unverified
Commit
49eb533a
authored
Mar 23, 2026
by
Calcium-Ion
Committed by
GitHub
Mar 23, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3381 from seefs001/feature/regex-ignored-upstream-models
feat: support regex-prefixed ignored upstream models
parents
7693edae
45f65c29
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
7 deletions
+30
-7
controller/channel_upstream_update.go
+9
-5
controller/channel_upstream_update_test.go
+12
-0
web/src/components/table/channels/modals/EditChannelModal.jsx
+6
-1
web/src/i18n/locales/en.json
+3
-1
No files found.
controller/channel_upstream_update.go
View file @
49eb533a
...
@@ -3,6 +3,7 @@ package controller
...
@@ -3,6 +3,7 @@ package controller
import
(
import
(
"fmt"
"fmt"
"net/http"
"net/http"
"regexp"
"slices"
"slices"
"strings"
"strings"
"sync"
"sync"
...
@@ -169,10 +170,7 @@ func collectPendingUpstreamModelChangesFromModels(
...
@@ -169,10 +170,7 @@ func collectPendingUpstreamModelChangesFromModels(
upstreamSet
[
modelName
]
=
struct
{}{}
upstreamSet
[
modelName
]
=
struct
{}{}
}
}
ignoredSet
:=
make
(
map
[
string
]
struct
{})
normalizedIgnoredModels
:=
normalizeModelNames
(
ignoredModels
)
for
_
,
modelName
:=
range
normalizeModelNames
(
ignoredModels
)
{
ignoredSet
[
modelName
]
=
struct
{}{}
}
redirectSourceSet
:=
make
(
map
[
string
]
struct
{},
len
(
modelMapping
))
redirectSourceSet
:=
make
(
map
[
string
]
struct
{},
len
(
modelMapping
))
redirectTargetSet
:=
make
(
map
[
string
]
struct
{},
len
(
modelMapping
))
redirectTargetSet
:=
make
(
map
[
string
]
struct
{},
len
(
modelMapping
))
...
@@ -193,7 +191,13 @@ func collectPendingUpstreamModelChangesFromModels(
...
@@ -193,7 +191,13 @@ func collectPendingUpstreamModelChangesFromModels(
if
_
,
ok
:=
coveredUpstreamSet
[
modelName
];
ok
{
if
_
,
ok
:=
coveredUpstreamSet
[
modelName
];
ok
{
return
false
return
false
}
}
if
_
,
ok
:=
ignoredSet
[
modelName
];
ok
{
if
lo
.
ContainsBy
(
normalizedIgnoredModels
,
func
(
ignoredModel
string
)
bool
{
if
regexBody
,
ok
:=
strings
.
CutPrefix
(
ignoredModel
,
"regex:"
);
ok
{
matched
,
err
:=
regexp
.
MatchString
(
strings
.
TrimSpace
(
regexBody
),
modelName
)
return
err
==
nil
&&
matched
}
return
ignoredModel
==
modelName
})
{
return
false
return
false
}
}
return
true
return
true
...
...
controller/channel_upstream_update_test.go
View file @
49eb533a
...
@@ -111,6 +111,18 @@ func TestCollectPendingUpstreamModelChangesFromModels_WithModelMapping(t *testin
...
@@ -111,6 +111,18 @@ func TestCollectPendingUpstreamModelChangesFromModels_WithModelMapping(t *testin
require
.
Equal
(
t
,
[]
string
{
"stale-model"
},
pendingRemoveModels
)
require
.
Equal
(
t
,
[]
string
{
"stale-model"
},
pendingRemoveModels
)
}
}
func
TestCollectPendingUpstreamModelChangesFromModels_WithIgnoredRegexPatterns
(
t
*
testing
.
T
)
{
pendingAddModels
,
pendingRemoveModels
:=
collectPendingUpstreamModelChangesFromModels
(
[]
string
{
"gpt-4o"
},
[]
string
{
"gpt-4o"
,
"claude-3-5-sonnet"
,
"sora-video"
,
"gpt-4.1"
},
[]
string
{
"regex:^sora-.*$"
,
"gpt-4.1"
},
nil
,
)
require
.
Equal
(
t
,
[]
string
{
"claude-3-5-sonnet"
},
pendingAddModels
)
require
.
Equal
(
t
,
[]
string
{},
pendingRemoveModels
)
}
func
TestBuildUpstreamModelUpdateTaskNotificationContent_OmitOverflowDetails
(
t
*
testing
.
T
)
{
func
TestBuildUpstreamModelUpdateTaskNotificationContent_OmitOverflowDetails
(
t
*
testing
.
T
)
{
channelSummaries
:=
make
([]
upstreamModelUpdateChannelSummary
,
0
,
12
)
channelSummaries
:=
make
([]
upstreamModelUpdateChannelSummary
,
0
,
12
)
for
i
:=
0
;
i
<
12
;
i
++
{
for
i
:=
0
;
i
<
12
;
i
++
{
...
...
web/src/components/table/channels/modals/EditChannelModal.jsx
View file @
49eb533a
...
@@ -3311,7 +3311,12 @@ const EditChannelModal = (props) => {
...
@@ -3311,7 +3311,12 @@ const EditChannelModal = (props) => {
<
Form
.
Input
<
Form
.
Input
field=
'upstream_model_update_ignored_models'
field=
'upstream_model_update_ignored_models'
label=
{
t
(
'已忽略模型'
)
}
label=
{
t
(
'已忽略模型'
)
}
placeholder=
{
t
(
'例如:gpt-4.1-nano,gpt-4o-mini'
)
}
placeholder=
{
t
(
'例如:gpt-4.1-nano,regex:^claude-.*$,regex:^sora-.*$'
,
)
}
extraText=
{
t
(
'支持精确匹配;使用 regex: 开头可按正则匹配。'
,
)
}
onChange=
{
(
value
)
=>
onChange=
{
(
value
)
=>
handleInputChange
(
handleInputChange
(
'upstream_model_update_ignored_models'
,
'upstream_model_update_ignored_models'
,
...
...
web/src/i18n/locales/en.json
View file @
49eb533a
...
@@ -3337,6 +3337,8 @@
...
@@ -3337,6 +3337,8 @@
"输入价格:{{symbol}}{{price}} / 1M tokens"
:
"Input Price: {{symbol}}{{price}} / 1M tokens"
,
"输入价格:{{symbol}}{{price}} / 1M tokens"
:
"Input Price: {{symbol}}{{price}} / 1M tokens"
,
"输出价格 {{symbol}}{{price}} / 1M tokens"
:
"Output Price {{symbol}}{{price}} / 1M tokens"
,
"输出价格 {{symbol}}{{price}} / 1M tokens"
:
"Output Price {{symbol}}{{price}} / 1M tokens"
,
"输出价格:{{symbol}}{{price}} / 1M tokens"
:
"Output Price: {{symbol}}{{price}} / 1M tokens"
,
"输出价格:{{symbol}}{{price}} / 1M tokens"
:
"Output Price: {{symbol}}{{price}} / 1M tokens"
,
"输出价格:{{symbol}}{{total}} / 1M tokens"
:
"Output Price: {{symbol}}{{total}} / 1M tokens"
"输出价格:{{symbol}}{{total}} / 1M tokens"
:
"Output Price: {{symbol}}{{total}} / 1M tokens"
,
"例如:gpt-4.1-nano,regex:^claude-.*$,regex:^sora-.*$"
:
"Example: gpt-4.1-nano,regex:^claude-.*$,regex:^sora-.*$"
,
"支持精确匹配;使用 regex: 开头可按正则匹配。"
:
"Supports exact matching. Use a regex: prefix for regex matching."
}
}
}
}
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