🚀 feature: Add request duration

This commit is contained in:
MartialBE
2023-12-30 00:37:14 +08:00
parent 943d90856f
commit a214371a0a
5 changed files with 41 additions and 25 deletions

View File

@@ -11,6 +11,7 @@ const LogTableHead = ({ userIsAdmin }) => {
<TableCell>令牌</TableCell>
<TableCell>类型</TableCell>
<TableCell>模型</TableCell>
<TableCell>耗时</TableCell>
<TableCell>提示</TableCell>
<TableCell>补全</TableCell>
<TableCell>额度</TableCell>

View File

@@ -25,7 +25,25 @@ function renderType(type) {
}
}
function requestTimeLabelOptions(request_time) {
let color = 'error';
if (request_time === 0) {
color = 'default';
} else if (request_time <= 1000) {
color = 'success';
} else if (request_time <= 3000) {
color = 'primary';
} else if (request_time <= 5000) {
color = 'secondary';
}
return color;
}
export default function LogTableRow({ item, userIsAdmin }) {
let request_time = item.request_time / 1000;
request_time = request_time.toFixed(2) + ' 秒';
return (
<>
<TableRow tabIndex={item.id}>
@@ -54,6 +72,10 @@ export default function LogTableRow({ item, userIsAdmin }) {
</Label>
)}
</TableCell>
<TableCell>
{' '}
<Label color={requestTimeLabelOptions(item.request_time)}> {item.request_time == 0 ? '无' : request_time} </Label>
</TableCell>
<TableCell>{item.prompt_tokens || ''}</TableCell>
<TableCell>{item.completion_tokens || ''}</TableCell>
<TableCell>{item.quota ? renderQuota(item.quota, 6) : ''}</TableCell>