Skip to content

Commit 73eb21e

Browse files
committed
Improved Chat Stats on Mouseover
1 parent 4f56f67 commit 73eb21e

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

tools/server/public/index.html.gz

196 Bytes
Binary file not shown.

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

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,22 @@ export default function ChatMessage({
3737
onChangeSibling(sibling: Message['id']): void;
3838
isPending?: boolean;
3939
}) {
40-
const { viewingChat, config } = useAppContext();
40+
const { viewingChat, config, serverProps } = useAppContext();
41+
42+
if (serverProps) {
43+
// Add debugging:
44+
console.log('ChatMessage - serverProps: ', serverProps);
45+
console.log('ChatMessage - serverProps type: ', typeof serverProps);
46+
console.log(
47+
'ChatMessage - serverProps keys: ',
48+
serverProps ? Object.keys(serverProps) : 'null'
49+
);
50+
console.log('ChatMessage - n_ctx direct: ', serverProps?.n_ctx);
51+
console.log(
52+
'ChatMessage - currently loaded model: ',
53+
serverProps?.model_path
54+
);
55+
}
4156
const [editingContent, setEditingContent] = useState<string | null>(null);
4257
const timings = useMemo(
4358
() =>
@@ -103,6 +118,9 @@ export default function ChatMessage({
103118

104119
const isUser = msg.role === 'user';
105120

121+
// @ts-expect-error/ban-ts-comment
122+
const contextSize = serverProps?.['default_generation_settings']?.['n_ctx'];
123+
106124
return (
107125
<div
108126
className="group"
@@ -195,18 +213,34 @@ export default function ChatMessage({
195213
Tokens: {timings.prompt_n + timings.predicted_n} this msg,{' '}
196214
{conversationTotal} total
197215
</div>
198-
<div className="dropdown-content bg-base-100 z-10 w-64 p-2 shadow mt-4">
199-
<b>This Exchange</b>
200-
<br />- Prompt: {timings.prompt_n} tokens
201-
<br />- Generation: {timings.predicted_n} tokens
202-
<br />- Subtotal: {timings.prompt_n +
203-
timings.predicted_n}{' '}
204-
tokens
205-
<br />- Speed test:{' '}
206-
{timings.predicted_per_second.toFixed(1)} t/s
216+
<div className="dropdown-content bg-base-100 z-10 w-64 p-2 shadow mt-4 h-80 overflow-y-auto">
217+
<h3>Chat Stats:</h3>
218+
<b>This Response</b>
219+
<br />- Generated: {timings.predicted_n} tokens
220+
<br />- Speed: {timings.predicted_per_second.toFixed(1)} t/s
207221
<br />
208-
<b>Conversation Total</b>
209-
<br />- Used: {conversationTotal} tokens
222+
<b>Total Conversation</b>
223+
<br />- Context used:{' '}
224+
{timings.prompt_n + timings.predicted_n} tokens
225+
<br />- Prompt history: {timings.prompt_n} tokens
226+
<br />- This response: {timings.predicted_n} tokens
227+
{contextSize && (
228+
<>
229+
<br />- Context limit: {contextSize} tokens
230+
<br />- Remaining:{' '}
231+
{contextSize -
232+
timings.prompt_n -
233+
timings.predicted_n}{' '}
234+
tokens
235+
<br />- Usage:{' '}
236+
{Math.round(
237+
((timings.prompt_n + timings.predicted_n) /
238+
contextSize) *
239+
100
240+
)}
241+
%
242+
</>
243+
)}
210244
</div>
211245
</div>
212246
)}

0 commit comments

Comments
 (0)