feat: 日志优化逻辑,新增请求时间和是否为stream字段

This commit is contained in:
CaIon
2024-01-21 15:01:59 +08:00
parent 800f494698
commit cbdce181af
8 changed files with 52 additions and 11 deletions

View File

@@ -54,5 +54,5 @@
"singleQuote": true,
"jsxSingleQuote": true
},
"proxy": "https://nekoapi.com"
"proxy": "http://localhost:3000"
}

View File

@@ -2,7 +2,7 @@ import React, {useEffect, useState} from 'react';
import {Label} from 'semantic-ui-react';
import {API, copy, isAdmin, showError, showSuccess, timestamp2string} from '../helpers';
import {Table, Avatar, Tag, Form, Button, Layout, Select, Popover, Modal, Spin} from '@douyinfe/semi-ui';
import {Table, Avatar, Tag, Form, Button, Layout, Select, Popover, Modal, Spin, Space} from '@douyinfe/semi-ui';
import {ITEMS_PER_PAGE} from '../constants';
import {renderNumber, renderQuota, stringToColor} from '../helpers/render';
import {
@@ -56,6 +56,25 @@ function renderType(type) {
}
}
function renderIsStream(bool) {
if (bool) {
return <Tag color='blue' size='large'></Tag>;
} else {
return <Tag color='purple' size='large'>非流</Tag>;
}
}
function renderUseTime(type) {
const time = parseInt(type);
if (time < 101) {
return <Tag color='green' size='large'> {time} s </Tag>;
} else if (time < 300) {
return <Tag color='orange' size='large'> {time} s </Tag>;
} else {
return <Tag color='red' size='large'> {time} s </Tag>;
}
}
const LogsTable = () => {
const columns = [
{
@@ -142,6 +161,20 @@ const LogsTable = () => {
);
},
},
{
title: '用时',
dataIndex: 'use_time',
render: (text, record, index) => {
return (
<div>
<Space>
{renderUseTime(text)}
{renderIsStream(record.is_stream)}
</Space>
</div>
);
},
},
{
title: '提示',
dataIndex: 'prompt_tokens',

View File

@@ -1,5 +1,4 @@
import React from 'react';
import { Header, Segment } from 'semantic-ui-react';
import LogsTable from '../../components/LogsTable';
const Token = () => (