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
de1590f5
authored
Oct 14, 2025
by
Seefs
Committed by
GitHub
Oct 14, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2038 from seefs001/feature/endpoint_type_log
feat: endpoint type log
parents
c62daee6
31f565b8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
5 deletions
+43
-5
controller/relay.go
+3
-0
relay/mjproxy_handler.go
+2
-2
relay/relay_task.go
+3
-0
service/log_info_generate.go
+24
-1
web/src/hooks/usage-logs/useUsageLogsData.jsx
+6
-0
web/src/i18n/locales/en.json
+1
-0
web/src/i18n/locales/fr.json
+2
-2
web/src/i18n/locales/ru.json
+1
-0
web/src/i18n/locales/zh.json
+1
-0
No files found.
controller/relay.go
View file @
de1590f5
...
...
@@ -299,6 +299,9 @@ func processChannelError(c *gin.Context, channelError types.ChannelError, err *t
userGroup
:=
c
.
GetString
(
"group"
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
other
:=
make
(
map
[
string
]
interface
{})
if
c
.
Request
!=
nil
&&
c
.
Request
.
URL
!=
nil
{
other
[
"request_path"
]
=
c
.
Request
.
URL
.
Path
}
other
[
"error_type"
]
=
err
.
GetErrorType
()
other
[
"error_code"
]
=
err
.
GetErrorCode
()
other
[
"status_code"
]
=
err
.
StatusCode
...
...
relay/mjproxy_handler.go
View file @
de1590f5
...
...
@@ -218,7 +218,7 @@ func RelaySwapFace(c *gin.Context, info *relaycommon.RelayInfo) *dto.MidjourneyR
tokenName
:=
c
.
GetString
(
"token_name"
)
logContent
:=
fmt
.
Sprintf
(
"模型固定价格 %.2f,分组倍率 %.2f,操作 %s"
,
priceData
.
ModelPrice
,
priceData
.
GroupRatioInfo
.
GroupRatio
,
constant
.
MjActionSwapFace
)
other
:=
service
.
GenerateMjOtherInfo
(
priceData
)
other
:=
service
.
GenerateMjOtherInfo
(
info
,
priceData
)
model
.
RecordConsumeLog
(
c
,
info
.
UserId
,
model
.
RecordConsumeLogParams
{
ChannelId
:
info
.
ChannelId
,
ModelName
:
modelName
,
...
...
@@ -518,7 +518,7 @@ func RelayMidjourneySubmit(c *gin.Context, relayInfo *relaycommon.RelayInfo) *dt
}
tokenName
:=
c
.
GetString
(
"token_name"
)
logContent
:=
fmt
.
Sprintf
(
"模型固定价格 %.2f,分组倍率 %.2f,操作 %s,ID %s"
,
priceData
.
ModelPrice
,
priceData
.
GroupRatioInfo
.
GroupRatio
,
midjRequest
.
Action
,
midjResponse
.
Result
)
other
:=
service
.
GenerateMjOtherInfo
(
priceData
)
other
:=
service
.
GenerateMjOtherInfo
(
relayInfo
,
priceData
)
model
.
RecordConsumeLog
(
c
,
relayInfo
.
UserId
,
model
.
RecordConsumeLogParams
{
ChannelId
:
relayInfo
.
ChannelId
,
ModelName
:
modelName
,
...
...
relay/relay_task.go
View file @
de1590f5
...
...
@@ -165,6 +165,9 @@ func RelayTaskSubmit(c *gin.Context, info *relaycommon.RelayInfo) (taskErr *dto.
}
}
other
:=
make
(
map
[
string
]
interface
{})
if
c
!=
nil
&&
c
.
Request
!=
nil
&&
c
.
Request
.
URL
!=
nil
{
other
[
"request_path"
]
=
c
.
Request
.
URL
.
Path
}
other
[
"model_price"
]
=
modelPrice
other
[
"group_ratio"
]
=
groupRatio
if
hasUserGroupRatio
{
...
...
service/log_info_generate.go
View file @
de1590f5
package
service
import
(
"strings"
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/dto"
...
...
@@ -10,6 +12,25 @@ import (
"github.com/gin-gonic/gin"
)
func
appendRequestPath
(
ctx
*
gin
.
Context
,
relayInfo
*
relaycommon
.
RelayInfo
,
other
map
[
string
]
interface
{})
{
if
other
==
nil
{
return
}
if
ctx
!=
nil
&&
ctx
.
Request
!=
nil
&&
ctx
.
Request
.
URL
!=
nil
{
if
path
:=
ctx
.
Request
.
URL
.
Path
;
path
!=
""
{
other
[
"request_path"
]
=
path
return
}
}
if
relayInfo
!=
nil
&&
relayInfo
.
RequestURLPath
!=
""
{
path
:=
relayInfo
.
RequestURLPath
if
idx
:=
strings
.
Index
(
path
,
"?"
);
idx
!=
-
1
{
path
=
path
[
:
idx
]
}
other
[
"request_path"
]
=
path
}
}
func
GenerateTextOtherInfo
(
ctx
*
gin
.
Context
,
relayInfo
*
relaycommon
.
RelayInfo
,
modelRatio
,
groupRatio
,
completionRatio
float64
,
cacheTokens
int
,
cacheRatio
float64
,
modelPrice
float64
,
userGroupRatio
float64
)
map
[
string
]
interface
{}
{
other
:=
make
(
map
[
string
]
interface
{})
...
...
@@ -42,6 +63,7 @@ func GenerateTextOtherInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, m
adminInfo
[
"multi_key_index"
]
=
common
.
GetContextKeyInt
(
ctx
,
constant
.
ContextKeyChannelMultiKeyIndex
)
}
other
[
"admin_info"
]
=
adminInfo
appendRequestPath
(
ctx
,
relayInfo
,
other
)
return
other
}
...
...
@@ -78,12 +100,13 @@ func GenerateClaudeOtherInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo,
return
info
}
func
GenerateMjOtherInfo
(
priceData
types
.
PerCallPriceData
)
map
[
string
]
interface
{}
{
func
GenerateMjOtherInfo
(
relayInfo
*
relaycommon
.
RelayInfo
,
priceData
types
.
PerCallPriceData
)
map
[
string
]
interface
{}
{
other
:=
make
(
map
[
string
]
interface
{})
other
[
"model_price"
]
=
priceData
.
ModelPrice
other
[
"group_ratio"
]
=
priceData
.
GroupRatioInfo
.
GroupRatio
if
priceData
.
GroupRatioInfo
.
HasSpecialRatio
{
other
[
"user_group_ratio"
]
=
priceData
.
GroupRatioInfo
.
GroupSpecialRatio
}
appendRequestPath
(
nil
,
relayInfo
,
other
)
return
other
}
web/src/hooks/usage-logs/useUsageLogsData.jsx
View file @
de1590f5
...
...
@@ -468,6 +468,12 @@ export const useLogsData = () => {
});
}
}
if
(
other
?.
request_path
)
{
expandDataLocal
.
push
({
key
:
t
(
'请求路径'
),
value
:
other
.
request_path
,
});
}
expandDatesLocal
[
logs
[
i
].
key
]
=
expandDataLocal
;
}
...
...
web/src/i18n/locales/en.json
View file @
de1590f5
...
...
@@ -1675,6 +1675,7 @@
"请求失败"
:
"Request failed"
,
"请求头覆盖"
:
"Request header override"
,
"请求并计费模型"
:
"Request and charge model"
,
"请求路径"
:
"Request path"
,
"请求时长: ${time}s"
:
"Request time: ${time}s"
,
"请求次数"
:
"Number of Requests"
,
"请求结束后多退少补"
:
"Adjust after request completion"
,
...
...
web/src/i18n/locales/fr.json
View file @
de1590f5
...
...
@@ -1684,6 +1684,7 @@
"请求失败"
:
"Échec de la demande"
,
"请求头覆盖"
:
"Remplacement des en-têtes de demande"
,
"请求并计费模型"
:
"Modèle de demande et de facturation"
,
"请求路径"
:
"Chemin de requête"
,
"请求时长: ${time}s"
:
"Durée de la requête : ${time}s"
,
"请求次数"
:
"Nombre de demandes"
,
"请求结束后多退少补"
:
"Ajuster après la fin de la demande"
,
...
...
@@ -2081,4 +2082,4 @@
"默认测试模型"
:
"Modèle de test par défaut"
,
"默认补全倍率"
:
"Taux de complétion par défaut"
}
}
\ No newline at end of file
}
web/src/i18n/locales/ru.json
View file @
de1590f5
...
...
@@ -1693,6 +1693,7 @@
"请求失败"
:
"Запрос не удался"
,
"请求头覆盖"
:
"Переопределение заголовков запроса"
,
"请求并计费模型"
:
"Запрос и выставление счёта модели"
,
"请求路径"
:
"Путь запроса"
,
"请求时长: ${time}s"
:
"Время запроса: ${time}s"
,
"请求次数"
:
"Количество запросов"
,
"请求结束后多退少补"
:
"После вывода запроса возврат излишков и доплата недостатка"
,
...
...
web/src/i18n/locales/zh.json
View file @
de1590f5
...
...
@@ -1666,6 +1666,7 @@
"请求失败"
:
"请求失败"
,
"请求头覆盖"
:
"请求头覆盖"
,
"请求并计费模型"
:
"请求并计费模型"
,
"请求路径"
:
"请求路径"
,
"请求时长: ${time}s"
:
"请求时长: ${time}s"
,
"请求次数"
:
"请求次数"
,
"请求结束后多退少补"
:
"请求结束后多退少补"
,
...
...
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