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
45f65c29
authored
Mar 22, 2026
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support regex-prefixed ignored upstream models
parent
deff59a5
Show 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 @
45f65c29
...
...
@@ -3,6 +3,7 @@ package controller
import
(
"fmt"
"net/http"
"regexp"
"slices"
"strings"
"sync"
...
...
@@ -169,10 +170,7 @@ func collectPendingUpstreamModelChangesFromModels(
upstreamSet
[
modelName
]
=
struct
{}{}
}
ignoredSet
:=
make
(
map
[
string
]
struct
{})
for
_
,
modelName
:=
range
normalizeModelNames
(
ignoredModels
)
{
ignoredSet
[
modelName
]
=
struct
{}{}
}
normalizedIgnoredModels
:=
normalizeModelNames
(
ignoredModels
)
redirectSourceSet
:=
make
(
map
[
string
]
struct
{},
len
(
modelMapping
))
redirectTargetSet
:=
make
(
map
[
string
]
struct
{},
len
(
modelMapping
))
...
...
@@ -193,7 +191,13 @@ func collectPendingUpstreamModelChangesFromModels(
if
_
,
ok
:=
coveredUpstreamSet
[
modelName
];
ok
{
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
true
...
...
controller/channel_upstream_update_test.go
View file @
45f65c29
...
...
@@ -111,6 +111,18 @@ func TestCollectPendingUpstreamModelChangesFromModels_WithModelMapping(t *testin
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
)
{
channelSummaries
:=
make
([]
upstreamModelUpdateChannelSummary
,
0
,
12
)
for
i
:=
0
;
i
<
12
;
i
++
{
...
...
web/src/components/table/channels/modals/EditChannelModal.jsx
View file @
45f65c29
...
...
@@ -3294,7 +3294,12 @@ const EditChannelModal = (props) => {
<
Form
.
Input
field=
'upstream_model_update_ignored_models'
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
)
=>
handleInputChange
(
'upstream_model_update_ignored_models'
,
...
...
web/src/i18n/locales/en.json
View file @
45f65c29
...
...
@@ -3337,6 +3337,8 @@
"输入价格:{{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}}{{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