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
7ef16363
authored
May 13, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 完善日志详情
parent
076e6602
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
14 deletions
+23
-14
relay/relay-text.go
+2
-2
web/src/components/LogsTable.js
+2
-4
web/src/helpers/render.js
+19
-8
No files found.
relay/relay-text.go
View file @
7ef16363
...
@@ -268,8 +268,8 @@ func postConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, textRe
...
@@ -268,8 +268,8 @@ func postConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, textRe
quota
:=
0
quota
:=
0
if
modelPrice
==
-
1
{
if
modelPrice
==
-
1
{
quota
=
promptTokens
+
int
(
float64
(
completionTokens
)
*
completionRatio
)
quota
=
promptTokens
+
int
(
math
.
Round
(
float64
(
completionTokens
)
*
completionRatio
)
)
quota
=
int
(
float64
(
quota
)
*
ratio
)
quota
=
int
(
math
.
Round
(
float64
(
quota
)
*
ratio
)
)
if
ratio
!=
0
&&
quota
<=
0
{
if
ratio
!=
0
&&
quota
<=
0
{
quota
=
1
quota
=
1
}
}
...
...
web/src/components/LogsTable.js
View file @
7ef16363
...
@@ -316,6 +316,8 @@ const LogsTable = () => {
...
@@ -316,6 +316,8 @@ const LogsTable = () => {
}
}
let
other
=
JSON
.
parse
(
record
.
other
);
let
other
=
JSON
.
parse
(
record
.
other
);
let
content
=
renderModelPrice
(
let
content
=
renderModelPrice
(
record
.
prompt_tokens
,
record
.
completion_tokens
,
other
.
model_ratio
,
other
.
model_ratio
,
other
.
model_price
,
other
.
model_price
,
other
.
completion_ratio
,
other
.
completion_ratio
,
...
@@ -326,10 +328,6 @@ const LogsTable = () => {
...
@@ -326,10 +328,6 @@ const LogsTable = () => {
<
Paragraph
<
Paragraph
ellipsis
=
{{
ellipsis
=
{{
rows
:
2
,
rows
:
2
,
showTooltip
:
{
type
:
'popover'
,
opts
:
{
style
:
{
width
:
240
}
},
},
}}
}}
style
=
{{
maxWidth
:
240
}}
style
=
{{
maxWidth
:
240
}}
>
>
...
...
web/src/helpers/render.js
View file @
7ef16363
...
@@ -135,6 +135,8 @@ export function renderQuota(quota, digits = 2) {
...
@@ -135,6 +135,8 @@ export function renderQuota(quota, digits = 2) {
}
}
export
function
renderModelPrice
(
export
function
renderModelPrice
(
inputTokens
,
completionTokens
,
modelRatio
,
modelRatio
,
modelPrice
=
-
1
,
modelPrice
=
-
1
,
completionRatio
,
completionRatio
,
...
@@ -147,15 +149,24 @@ export function renderModelPrice(
...
@@ -147,15 +149,24 @@ export function renderModelPrice(
if
(
completionRatio
===
undefined
)
{
if
(
completionRatio
===
undefined
)
{
completionRatio
=
0
;
completionRatio
=
0
;
}
}
let
inputRatioPrice
=
modelRatio
*
0.002
*
groupRatio
;
let
inputRatioPrice
=
modelRatio
*
2.0
*
groupRatio
;
let
completionRatioPrice
=
let
completionRatioPrice
=
modelRatio
*
completionRatio
*
2.0
*
groupRatio
;
modelRatio
*
completionRatio
*
0.002
*
groupRatio
;
let
price
=
(
inputTokens
/
1000000
)
*
inputRatioPrice
+
(
completionTokens
/
1000000
)
*
completionRatioPrice
;
return
(
return
(
'输入 $'
+
<>
inputRatioPrice
.
toFixed
(
3
)
+
<
article
>
'/1K tokens,补全 $'
+
<
p
>
提示
$
{
inputRatioPrice
}
/ 1M tokens</
p
>
completionRatioPrice
.
toFixed
(
3
)
+
<
p
>
补全
$
{
completionRatioPrice
}
/ 1M tokens</
p
>
'/1K tokens'
<
p
>
计算过程:
<
/p
>
<
p
>
提示
{
inputTokens
}
tokens
/
1
M
tokens
*
$
{
inputRatioPrice
}
+
补全
{
' '
}
{
completionTokens
}
tokens
/
1
M
tokens
*
$
{
completionRatioPrice
}
=
$
{
price
.
toFixed
(
6
)}
<
/p
>
<
/article
>
<
/
>
);
);
}
}
}
}
...
...
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