@@ -88,14 +88,22 @@ export default class AiUsage extends Component {
8888 return normalized;
8989 }
9090
91- // Then modify the chartConfig getter to use this normalized data:
9291 get chartConfig () {
9392 if (! this .data ? .data ) {
9493 return ;
9594 }
9695
9796 const normalizedData = this .normalizeTimeSeriesData (this .data .data );
9897
98+ const chartEl = document .querySelector (" .ai-usage__chart" );
99+ const computedStyle = getComputedStyle (chartEl);
100+
101+ const colors = {
102+ response: computedStyle .getPropertyValue (" --chart-response-color" ).trim (),
103+ request: computedStyle .getPropertyValue (" --chart-request-color" ).trim (),
104+ cached: computedStyle .getPropertyValue (" --chart-cached-color" ).trim (),
105+ };
106+
99107 return {
100108 type: " bar" ,
101109 data: {
@@ -107,17 +115,19 @@ export default class AiUsage extends Component {
107115 {
108116 label: " Response Tokens" ,
109117 data: normalizedData .map ((row ) => row .total_response_tokens ),
110- backgroundColor: " rgba(75, 192, 192, 0.8) " ,
118+ backgroundColor: colors . response ,
111119 },
112120 {
113- label: " Request Tokens" ,
114- data: normalizedData .map ((row ) => row .total_request_tokens ),
115- backgroundColor: " rgba(153, 102, 255, 0.8)" ,
121+ label: " Net Request Tokens" ,
122+ data: normalizedData .map (
123+ (row ) => row .total_request_tokens - row .total_cached_tokens
124+ ),
125+ backgroundColor: colors .request ,
116126 },
117127 {
118- label: " Cached Tokens" ,
128+ label: " Cached Request Tokens" ,
119129 data: normalizedData .map ((row ) => row .total_cached_tokens ),
120- backgroundColor: " rgba(255, 159, 64, 0.8) " ,
130+ backgroundColor: colors . cached ,
121131 },
122132 ],
123133 },
@@ -296,6 +306,37 @@ export default class AiUsage extends Component {
296306 </div >
297307
298308 <div class =" ai-usage__breakdowns" >
309+
310+ <div class =" ai-usage__users" >
311+ <h3 class =" ai-usage__users-title" >
312+ {{i18n " discourse_ai.usage.users_breakdown" }}
313+ </h3 >
314+ <table class =" ai-usage__users-table" >
315+ <thead >
316+ <tr >
317+ <th >{{i18n " discourse_ai.usage.username" }} </th >
318+ <th >{{i18n " discourse_ai.usage.usage_count" }} </th >
319+ <th >{{i18n " discourse_ai.usage.total_tokens" }} </th >
320+ </tr >
321+ </thead >
322+ <tbody >
323+ {{#each this . data.users as | user | }}
324+ <tr class =" ai-usage__users-row" >
325+ <td
326+ class =" ai-usage__users-cell"
327+ >{{user.username }} </td >
328+ <td
329+ class =" ai-usage__users-cell"
330+ >{{user.usage_count }} </td >
331+ <td
332+ class =" ai-usage__users-cell"
333+ >{{user.total_tokens }} </td >
334+ </tr >
335+ {{/each }}
336+ </tbody >
337+ </table >
338+ </div >
339+
299340 <div class =" ai-usage__features" >
300341 <h3 class =" ai-usage__features-title" >
301342 {{i18n " discourse_ai.usage.features_breakdown" }}
0 commit comments