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
bc80477b
authored
Mar 17, 2026
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: simplify param override audit UI and operation labels
parent
5db25f47
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
285 additions
and
152 deletions
+285
-152
relay/common/override.go
+0
-0
relay/common/override_test.go
+100
-0
web/src/components/table/usage-logs/components/ParamOverrideEntry.jsx
+54
-0
web/src/components/table/usage-logs/modals/ParamOverrideModal.jsx
+124
-130
web/src/hooks/usage-logs/useUsageLogsData.jsx
+7
-22
No files found.
relay/common/override.go
View file @
bc80477b
This diff is collapsed.
Click to expand it.
relay/common/override_test.go
View file @
bc80477b
...
...
@@ -6,6 +6,7 @@ import (
"reflect"
"testing"
common2
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/types"
"github.com/QuantumNous/new-api/dto"
...
...
@@ -2066,6 +2067,105 @@ func TestRemoveDisabledFieldsAllowInferenceGeo(t *testing.T) {
assertJSONEqual
(
t
,
`{"inference_geo":"eu","store":true}`
,
string
(
out
))
}
func
TestApplyParamOverrideWithRelayInfoRecordsOperationAuditInDebugMode
(
t
*
testing
.
T
)
{
originalDebugEnabled
:=
common2
.
DebugEnabled
common2
.
DebugEnabled
=
true
t
.
Cleanup
(
func
()
{
common2
.
DebugEnabled
=
originalDebugEnabled
})
info
:=
&
RelayInfo
{
ChannelMeta
:
&
ChannelMeta
{
ParamOverride
:
map
[
string
]
interface
{}{
"operations"
:
[]
interface
{}{
map
[
string
]
interface
{}{
"mode"
:
"copy"
,
"from"
:
"metadata.target_model"
,
"to"
:
"model"
,
},
map
[
string
]
interface
{}{
"mode"
:
"set"
,
"path"
:
"service_tier"
,
"value"
:
"flex"
,
},
map
[
string
]
interface
{}{
"mode"
:
"set"
,
"path"
:
"temperature"
,
"value"
:
0.1
,
},
},
},
},
}
out
,
err
:=
ApplyParamOverrideWithRelayInfo
([]
byte
(
`{
"model":"gpt-4.1",
"temperature":0.7,
"metadata":{"target_model":"gpt-4.1-mini"}
}`
),
info
)
if
err
!=
nil
{
t
.
Fatalf
(
"ApplyParamOverrideWithRelayInfo returned error: %v"
,
err
)
}
assertJSONEqual
(
t
,
`{
"model":"gpt-4.1-mini",
"temperature":0.1,
"service_tier":"flex",
"metadata":{"target_model":"gpt-4.1-mini"}
}`
,
string
(
out
))
expected
:=
[]
string
{
"copy metadata.target_model -> model"
,
"set service_tier = flex"
,
"set temperature = 0.1"
,
}
if
!
reflect
.
DeepEqual
(
info
.
ParamOverrideAudit
,
expected
)
{
t
.
Fatalf
(
"unexpected param override audit, got %#v"
,
info
.
ParamOverrideAudit
)
}
}
func
TestApplyParamOverrideWithRelayInfoRecordsOnlyKeyOperationsWhenDebugDisabled
(
t
*
testing
.
T
)
{
originalDebugEnabled
:=
common2
.
DebugEnabled
common2
.
DebugEnabled
=
false
t
.
Cleanup
(
func
()
{
common2
.
DebugEnabled
=
originalDebugEnabled
})
info
:=
&
RelayInfo
{
ChannelMeta
:
&
ChannelMeta
{
ParamOverride
:
map
[
string
]
interface
{}{
"operations"
:
[]
interface
{}{
map
[
string
]
interface
{}{
"mode"
:
"copy"
,
"from"
:
"metadata.target_model"
,
"to"
:
"model"
,
},
map
[
string
]
interface
{}{
"mode"
:
"set"
,
"path"
:
"temperature"
,
"value"
:
0.1
,
},
},
},
},
}
_
,
err
:=
ApplyParamOverrideWithRelayInfo
([]
byte
(
`{
"model":"gpt-4.1",
"temperature":0.7,
"metadata":{"target_model":"gpt-4.1-mini"}
}`
),
info
)
if
err
!=
nil
{
t
.
Fatalf
(
"ApplyParamOverrideWithRelayInfo returned error: %v"
,
err
)
}
expected
:=
[]
string
{
"copy metadata.target_model -> model"
,
}
if
!
reflect
.
DeepEqual
(
info
.
ParamOverrideAudit
,
expected
)
{
t
.
Fatalf
(
"unexpected param override audit, got %#v"
,
info
.
ParamOverrideAudit
)
}
}
func
assertJSONEqual
(
t
*
testing
.
T
,
want
,
got
string
)
{
t
.
Helper
()
...
...
web/src/components/table/usage-logs/components/ParamOverrideEntry.jsx
0 → 100644
View file @
bc80477b
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import
React
from
'react'
;
import
{
Typography
}
from
'@douyinfe/semi-ui'
;
const
{
Text
}
=
Typography
;
const
ParamOverrideEntry
=
({
count
,
onOpen
,
t
})
=>
{
return
(
<
div
style=
{
{
display
:
'flex'
,
alignItems
:
'center'
,
gap
:
10
,
flexWrap
:
'wrap'
,
}
}
>
<
Text
type=
'tertiary'
size=
'small'
style=
{
{
fontVariantNumeric
:
'tabular-nums'
}
}
>
{
t
(
'
{{
count
}}
项操作'
,
{
count
})
}
</
Text
>
<
Text
link
size=
'small'
style=
{
{
fontWeight
:
600
}
}
onClick=
{
onOpen
}
>
{
t
(
'查看详情'
)
}
</
Text
>
</
div
>
);
};
export
default
React
.
memo
(
ParamOverrideEntry
);
web/src/components/table/usage-logs/modals/ParamOverrideModal.jsx
View file @
bc80477b
This diff is collapsed.
Click to expand it.
web/src/hooks/usage-logs/useUsageLogsData.jsx
View file @
bc80477b
...
...
@@ -19,7 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
import
{
useState
,
useEffect
}
from
'react'
;
import
{
useTranslation
}
from
'react-i18next'
;
import
{
Modal
,
Button
,
Tag
}
from
'@douyinfe/semi-ui'
;
import
{
Modal
}
from
'@douyinfe/semi-ui'
;
import
{
API
,
getTodayStartTimestamp
,
...
...
@@ -39,6 +39,7 @@ import {
}
from
'../../helpers'
;
import
{
ITEMS_PER_PAGE
}
from
'../../constants'
;
import
{
useTableCompactMode
}
from
'../common/useTableCompactMode'
;
import
ParamOverrideEntry
from
'../../components/table/usage-logs/components/ParamOverrideEntry'
;
export
const
useLogsData
=
()
=>
{
const
{
t
}
=
useTranslation
();
...
...
@@ -604,30 +605,14 @@ export const useLogsData = () => {
expandDataLocal
.
push
({
key
:
t
(
'参数覆盖'
),
value
:
(
<
div
style=
{
{
display
:
'flex'
,
alignItems
:
'center'
,
gap
:
10
,
flexWrap
:
'wrap'
,
}
}
>
<
Tag
color=
'blue'
shape=
'circle'
>
{
t
(
'
{{
count
}}
项变更'
,
{
count
:
other
.
po
.
length
})
}
</
Tag
>
<
Button
theme=
'borderless'
type=
'primary'
size=
'small'
style=
{
{
paddingLeft
:
0
}
}
onClick=
{
(
event
)
=>
{
<
ParamOverrideEntry
count=
{
other
.
po
.
length
}
t=
{
t
}
onOpen=
{
(
event
)
=>
{
event
.
stopPropagation
();
openParamOverrideModal
(
logs
[
i
],
other
);
}
}
>
{
t
(
'查看详情'
)
}
</
Button
>
</
div
>
/>
),
});
}
...
...
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