Skip to content

Commit d3a95f6

Browse files
committed
Move Performance metric under icon
1 parent c052892 commit d3a95f6

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

tools/server/webui/src/components/ChatMessage.tsx

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ArrowPathIcon,
88
ChevronLeftIcon,
99
ChevronRightIcon,
10+
ExclamationCircleIcon,
1011
PencilSquareIcon,
1112
} from '@heroicons/react/24/outline';
1213
import ChatInputExtraContextItem from './ChatInputExtraContextItem';
@@ -109,7 +110,7 @@ export default function ChatMessage({
109110
<div
110111
className={classNames({
111112
'chat-bubble markdown': true,
112-
'chat-bubble bg-transparent': !isUser,
113+
'bg-transparent': !isUser,
113114
})}
114115
>
115116
{/* textarea for editing message */}
@@ -168,30 +169,6 @@ export default function ChatMessage({
168169
</div>
169170
</>
170171
)}
171-
{/* render timings if enabled */}
172-
{timings && config.showTokensPerSecond && (
173-
<div className="dropdown dropdown-hover dropdown-top mt-2">
174-
<div
175-
tabIndex={0}
176-
role="button"
177-
className="cursor-pointer font-semibold text-sm opacity-60"
178-
>
179-
Speed: {timings.predicted_per_second.toFixed(1)} t/s
180-
</div>
181-
<div className="dropdown-content bg-base-100 z-10 w-64 p-2 shadow mt-4">
182-
<b>Prompt</b>
183-
<br />- Tokens: {timings.prompt_n}
184-
<br />- Time: {timings.prompt_ms} ms
185-
<br />- Speed: {timings.prompt_per_second.toFixed(1)} t/s
186-
<br />
187-
<b>Generation</b>
188-
<br />- Tokens: {timings.predicted_n}
189-
<br />- Time: {timings.predicted_ms} ms
190-
<br />- Speed: {timings.predicted_per_second.toFixed(1)} t/s
191-
<br />
192-
</div>
193-
</div>
194-
)}
195172
</>
196173
)}
197174
</div>
@@ -201,7 +178,7 @@ export default function ChatMessage({
201178
{msg.content !== null && (
202179
<div
203180
className={classNames({
204-
'flex items-center gap-2 mx-4 mt-2 mb-2': true,
181+
'flex items-center gap-2 mx-4 mb-2': true,
205182
'flex-row-reverse': msg.role === 'user',
206183
})}
207184
>
@@ -264,6 +241,41 @@ export default function ChatMessage({
264241
<ArrowPathIcon className="h-4 w-4" />
265242
</BtnWithTooltips>
266243
)}
244+
245+
{/* render timings if enabled */}
246+
{timings && config.showTokensPerSecond && (
247+
<BtnWithTooltips
248+
className="btn-mini w-8 h-8"
249+
tooltipsContent="Performance"
250+
>
251+
<div className="dropdown dropdown-hover dropdown-top">
252+
<ExclamationCircleIcon className="h-4 w-4" />
253+
254+
<div
255+
tabIndex={0}
256+
className="dropdown-content rounded-box bg-base-100 z-10 w-48 px-4 py-2 shadow mt-4 text-sm text-left"
257+
>
258+
<b>Prompt Processing</b>
259+
<ul className="list-inside list-disc">
260+
<li>Tokens: {timings.prompt_n}</li>
261+
<li>Time: {timings.prompt_ms} ms</li>
262+
<li>
263+
Speed: {timings.prompt_per_second.toFixed(1)} t/s
264+
</li>
265+
</ul>
266+
<br />
267+
<b>Generation</b>
268+
<ul className="list-inside list-disc">
269+
<li>Tokens: {timings.predicted_n}</li>
270+
<li>Time: {timings.predicted_ms} ms</li>
271+
<li>
272+
Speed: {timings.predicted_per_second.toFixed(1)} t/s
273+
</li>
274+
</ul>
275+
</div>
276+
</div>
277+
</BtnWithTooltips>
278+
)}
267279
</>
268280
)}
269281
<CopyButton className="btn-mini w-8 h-8" content={msg.content} />

tools/server/webui/src/utils/common.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function BtnWithTooltips({
4646
disabled,
4747
}: {
4848
className?: string;
49-
onClick: () => void;
49+
onClick?: () => void;
5050
onMouseLeave?: () => void;
5151
children: React.ReactNode;
5252
tooltipsContent: string;

0 commit comments

Comments
 (0)