Skip to content

Commit d68fb15

Browse files
committed
release: v4.2.4
1 parent 0caca94 commit d68fb15

File tree

3 files changed

+92
-52
lines changed

3 files changed

+92
-52
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "surmon.me.admin",
3-
"version": "4.2.3",
3+
"version": "4.2.4",
44
"author": "Surmon",
55
"license": "MIT",
66
"homepage": "https://github.com/surmon-china/surmon.me.admin",

src/pages/AiAgent/Detail.tsx

Lines changed: 61 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { useShallowRef, onMounted } from 'veact'
33
import { useLoading } from 'veact-use'
44
import { Descriptions, Typography, List, Skeleton, Statistic, Avatar, Divider } from 'antd'
55
import * as Icons from '@ant-design/icons'
6-
import { AuthorName, AuthorEmail } from '@/components/common/AuthorProfile'
6+
import type { ChatSession, ChatMessage } from '@/constants/ai-agent'
7+
import { GeneralAuthorType, getAuthorTypeName } from '@/constants/author'
78
import { UniversalText } from '@/components/common/UniversalText'
89
import * as api from '@/apis/ai-agent'
9-
import type { ChatSession, ChatMessage } from '@/constants/ai-agent'
1010
import { timestampToYMD } from '@/transforms/date'
1111
import { APP_PRIMARY_COLOR } from '@/config'
1212

@@ -26,46 +26,58 @@ export const SessionDetail: React.FC<SessionDetailProps> = (props) => {
2626

2727
const renderSessionInfos = () => (
2828
<Descriptions
29-
column={4}
29+
column={1}
3030
items={[
3131
{
3232
key: 'id',
33-
span: 4,
3433
label: 'Session ID',
3534
children: <UniversalText text={props.session.session_id} copyable />
3635
},
3736
{
3837
key: 'content',
39-
span: 4,
4038
label: '最后对话时间',
4139
children: <UniversalText text={timestampToYMD(props.session.last_active * 1000)} />
42-
},
40+
}
41+
]}
42+
/>
43+
)
44+
45+
const renderUsageStats = () => (
46+
<Descriptions
47+
column={4}
48+
items={[
4349
{
4450
key: 'user_id',
4551
label: '用户 ID',
46-
children: <UniversalText text={props.session.user_id} placeholder="非登录用户" />
52+
children: (
53+
<UniversalText text={props.session.user_id} placeholder="非登录用户" strong={true} />
54+
)
4755
},
4856
{
4957
key: 'author_name',
5058
label: '用户名称',
51-
children: <AuthorName author_name={props.session.author_name} />
59+
children: (
60+
<UniversalText
61+
text={props.session.author_name}
62+
placeholder={getAuthorTypeName(GeneralAuthorType.Anonymous)}
63+
/>
64+
)
5265
},
5366
{
5467
key: 'author_email',
5568
span: 4,
56-
label: '用户邮箱',
57-
children: <AuthorEmail author_email={props.session.author_email} />
58-
},
59-
{
60-
key: 'message_count',
6169
children: (
62-
<Statistic
63-
title="消息数量"
64-
prefix={<Icons.MessageOutlined />}
65-
value={props.session.message_count}
70+
<UniversalText
71+
text={props.session.author_email}
72+
copyable={true}
73+
placeholder="无邮箱"
6674
/>
6775
)
6876
},
77+
{
78+
key: 'message_count',
79+
children: <Statistic title="消息数量" value={props.session.message_count} />
80+
},
6981
{
7082
key: 'total_tokens',
7183
children: <Statistic title="总用 Token" value={props.session.total_tokens} />
@@ -91,24 +103,38 @@ export const SessionDetail: React.FC<SessionDetailProps> = (props) => {
91103
<List.Item
92104
key={index}
93105
style={{ overflow: 'hidden' }}
94-
actions={[
95-
<UniversalText key="model" text={message.model} type="secondary" />,
96-
<UniversalText
97-
key="input_tokens"
98-
prefix="Input"
99-
text={message.input_tokens}
100-
type="secondary"
101-
/>,
102-
<UniversalText
103-
key="output_tokens"
104-
prefix="Output"
105-
text={message.output_tokens}
106-
type="secondary"
107-
/>
108-
]}
106+
actions={
107+
message.role === 'user'
108+
? []
109+
: [
110+
<UniversalText key="model" text={message.model} type="secondary" />,
111+
<UniversalText
112+
key="input_tokens"
113+
prefix="Input"
114+
text={message.input_tokens}
115+
type="secondary"
116+
/>,
117+
<UniversalText
118+
key="output_tokens"
119+
prefix="Output"
120+
text={message.output_tokens}
121+
type="secondary"
122+
/>
123+
]
124+
}
109125
>
110126
<List.Item.Meta
111-
title={<UniversalText text={message.role.toUpperCase()} strong={true} />}
127+
title={
128+
message.role === 'user' ? (
129+
<UniversalText
130+
text={props.session.author_name}
131+
placeholder={getAuthorTypeName(GeneralAuthorType.Anonymous)}
132+
strong={true}
133+
/>
134+
) : (
135+
<UniversalText text={message.role} strong={true} />
136+
)
137+
}
112138
description={timestampToYMD(message.created_at * 1000)}
113139
avatar={
114140
<Avatar
@@ -147,6 +173,8 @@ export const SessionDetail: React.FC<SessionDetailProps> = (props) => {
147173
<div>
148174
{renderSessionInfos()}
149175
<Divider />
176+
{renderUsageStats()}
177+
<Divider />
150178
{fetching.state.value ? <Skeleton /> : renderMessages()}
151179
</div>
152180
)

src/pages/AiAgent/TableList.tsx

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from 'react'
2-
import { Table, Space, Popover, Typography, Statistic } from 'antd'
2+
import { Table, Space, Popover, Typography } from 'antd'
33
import * as Icons from '@ant-design/icons'
44
import { ChatSession } from '@/constants/ai-agent'
55
import { GeneralAuthorType, getAuthorTypeName } from '@/constants/author'
6-
import { AuthorName, AuthorEmail } from '@/components/common/AuthorProfile'
76
import { UniversalText } from '@/components/common/UniversalText'
87
import { timestampToYMD } from '@/transforms/date'
98

@@ -24,15 +23,6 @@ export const TableList: React.FC<TableListProps> = (props) => {
2423
footer={() => props.footer}
2524
pagination={false}
2625
columns={[
27-
{
28-
title: 'session ID',
29-
dataIndex: 'session_id',
30-
render: (_, session, index) => (
31-
<Typography.Link onClick={() => props.onDetail(session.session_id, index)}>
32-
对话记录
33-
</Typography.Link>
34-
)
35-
},
3626
{
3727
title: '最后对话',
3828
ellipsis: true,
@@ -60,10 +50,10 @@ export const TableList: React.FC<TableListProps> = (props) => {
6050
minWidth: 100,
6151
ellipsis: true,
6252
dataIndex: 'message_count',
63-
render: (_, session) => <Statistic value={session.message_count} />
53+
render: (_, session) => <UniversalText text={session.message_count} strong={true} />
6454
},
6555
{
66-
title: 'Token 用量',
56+
title: 'Token 总用量',
6757
minWidth: 130,
6858
ellipsis: true,
6959
dataIndex: 'total_tokens',
@@ -79,7 +69,9 @@ export const TableList: React.FC<TableListProps> = (props) => {
7969
</Space>
8070
}
8171
>
82-
<Statistic value={session.total_tokens} />
72+
<span>
73+
<UniversalText text={session.total_tokens} strong={true} />
74+
</span>
8375
</Popover>
8476
)
8577
},
@@ -95,23 +87,43 @@ export const TableList: React.FC<TableListProps> = (props) => {
9587
content={
9688
<Space orientation="vertical" size="small">
9789
<UniversalText
98-
prefix={<Icons.UserOutlined />}
90+
prefix={<Icons.FieldNumberOutlined />}
9991
text={session.user_id}
10092
placeholder="非登录用户"
93+
strong={true}
94+
/>
95+
<UniversalText
96+
prefix={<Icons.UserOutlined />}
97+
text={session.author_name}
98+
placeholder={getAuthorTypeName(GeneralAuthorType.Anonymous)}
99+
/>
100+
<UniversalText
101+
prefix={<Icons.MailOutlined />}
102+
text={session.author_email}
103+
placeholder="无邮箱"
104+
copyable={true}
101105
/>
102-
<AuthorName author_name={session.author_name} icon={true} />
103-
<AuthorEmail author_email={session.author_email} icon={true} />
104106
</Space>
105107
}
106108
>
107109
<span>
108110
<UniversalText
109-
text={session.user_id || session.author_name}
111+
text={session.author_name}
110112
placeholder={getAuthorTypeName(GeneralAuthorType.Anonymous)}
113+
strong={true}
111114
/>
112115
</span>
113116
</Popover>
114117
)
118+
},
119+
{
120+
title: 'session',
121+
dataIndex: 'session_id',
122+
render: (_, session, index) => (
123+
<Typography.Link onClick={() => props.onDetail(session.session_id, index)}>
124+
对话记录
125+
</Typography.Link>
126+
)
115127
}
116128
]}
117129
/>

0 commit comments

Comments
 (0)