@@ -37,7 +37,22 @@ export default function ChatMessage({
37
37
onChangeSibling ( sibling : Message [ 'id' ] ) : void ;
38
38
isPending ?: boolean ;
39
39
} ) {
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
+ }
41
56
const [ editingContent , setEditingContent ] = useState < string | null > ( null ) ;
42
57
const timings = useMemo (
43
58
( ) =>
@@ -103,6 +118,9 @@ export default function ChatMessage({
103
118
104
119
const isUser = msg . role === 'user' ;
105
120
121
+ // @ts -expect-error/ban-ts-comment
122
+ const contextSize = serverProps ?. [ 'default_generation_settings' ] ?. [ 'n_ctx' ] ;
123
+
106
124
return (
107
125
< div
108
126
className = "group"
@@ -195,18 +213,34 @@ export default function ChatMessage({
195
213
Tokens: { timings . prompt_n + timings . predicted_n } this msg,{ ' ' }
196
214
{ conversationTotal } total
197
215
</ 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
207
221
< 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
+ ) }
210
244
</ div >
211
245
</ div >
212
246
) }
0 commit comments