Spaces:
Running
Running
File size: 2,104 Bytes
aa80aba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 'use strict';
const TokenUsage={
aggregate(answers){
const t={responses:0,input_total:0,output_total:0,input_avg:null,output_avg:null};
for(const a of answers){const u=a?.usage||{},i=u.prompt_tokens??u.input_tokens,o=u.completion_tokens??u.output_tokens;if(!Number.isInteger(i)||!Number.isInteger(o)||i<0||o<0)continue;t.responses++;t.input_total+=i;t.output_total+=o;}
if(t.responses){t.input_avg=t.input_total/t.responses;t.output_avg=t.output_total/t.responses;}return t;
},
format(n,avg=false){return typeof n==='number'&&Number.isFinite(n)?n.toLocaleString('en-US',{maximumFractionDigits:avg?1:0}):'โ';},
table(d,condition){
const e=s=>String(s??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
return `<div class="table-wrap token-summary"><table><caption>์ฑ๋ฅ ยท ์๋ต ์์ฑ ํ ํฐ</caption><thead><tr><th>Model</th><th>์๋ต / ์ฑ์ </th><th>์ ํ๋</th><th>์ด ์
๋ ฅ ํ ํฐ</th><th>๋ฌธํญ๋น ํ๊ท ์
๋ ฅ</th><th>์ด ์ถ๋ ฅ ํ ํฐ</th><th>๋ฌธํญ๋น ํ๊ท ์ถ๋ ฅ</th><th>ํ ํฐ ์ง๊ณ ๋ฌธํญ</th></tr></thead><tbody>${d.settings.filter(s=>s.condition===condition).map(s=>{const t=s.tokens,known=t&&t.responses>0;return `<tr><th>${e(s.label)}</th><td>${s.read} / ${s.graded}</td><td>${CleanResults.cell({n:d.total,graded:s.graded,correct:s.correct})}</td><td>${known?this.format(t.input_total):'โ'}</td><td>${known?this.format(t.input_avg,true):'โ'}</td><td>${known?this.format(t.output_total):'โ'}</td><td>${known?this.format(t.output_avg,true):'โ'}</td><td>${t?`${t.responses} / ${s.read}`:'์ง๊ณ ๋๊ธฐ'}</td></tr>`;}).join('')}</tbody></table></div><p class="caption">์๋ฃ๋ ์๋ต ์ค ํ ํฐ ์ฌ์ฉ๋์ด ๊ธฐ๋ก๋ ๋ฌธํญ ๊ธฐ์ค ยท ์ฑ์ /์๋ฒ ๋ฉ/์คํจ ์ฌ์๋ ์ ์ธ ยท ์
๋ ฅ์๋ ๋ณด๊ณ ๋ ์บ์ ํ ํฐ ํฌํจ ยท ๋ชจ๋ธ๋ณ ํ ํฌ๋์ด์ ๊ฐ ๋ฌ๋ผ ๋์ผ ์๋ฃ๋ ํ ํฐ ์๊ฐ ๋ค๋ฆ
๋๋ค.</p>`;
},
answer(a){const t=this.aggregate([a]);return t.responses?`์
๋ ฅ ${this.format(t.input_total)} ยท ์ถ๋ ฅ ${this.format(t.output_total)} ํ ํฐ`:'ํ ํฐ ์ฌ์ฉ๋ ๋ฏธ๊ธฐ๋ก';}
};
|