|
|
|
@ -4,7 +4,7 @@ |
|
|
|
var ENABLED_KEY = 'dshmem-log-enabled' |
|
|
|
var ENABLED_KEY = 'dshmem-log-enabled' |
|
|
|
var BASE = 'http' + ':' + '//' + '127.0.0.1' + ':' + '8766' |
|
|
|
var BASE = 'http' + ':' + '//' + '127.0.0.1' + ':' + '8766' |
|
|
|
var CHUNK = 700 |
|
|
|
var CHUNK = 700 |
|
|
|
var K_RATIO = 2.5 |
|
|
|
var K_RATIO = 3.1; var CONTEXT_LIMIT = 131072; var charsAccum = 0 |
|
|
|
var seen = Object.create(null) |
|
|
|
var seen = Object.create(null) |
|
|
|
var cfg = null |
|
|
|
var cfg = null |
|
|
|
var lastAccum = null |
|
|
|
var lastAccum = null |
|
|
|
@ -193,7 +193,7 @@ |
|
|
|
for (var m = 0; m !== all.length; m++) { |
|
|
|
for (var m = 0; m !== all.length; m++) { |
|
|
|
if (all[m] && typeof all[m].content === 'string') ctxChars += all[m].content.length |
|
|
|
if (all[m] && typeof all[m].content === 'string') ctxChars += all[m].content.length |
|
|
|
} |
|
|
|
} |
|
|
|
var meta = { |
|
|
|
charsAccum += ctxChars; var meta = { |
|
|
|
mid: 'meta-' + Date.now(), |
|
|
|
mid: 'meta-' + Date.now(), |
|
|
|
part: 0, |
|
|
|
part: 0, |
|
|
|
total: 1, |
|
|
|
total: 1, |
|
|
|
@ -204,9 +204,9 @@ |
|
|
|
accum: accum, |
|
|
|
accum: accum, |
|
|
|
delta: delta, |
|
|
|
delta: delta, |
|
|
|
chars: ctxChars, |
|
|
|
chars: ctxChars, |
|
|
|
est_tok: Math.round(ctxChars / K_RATIO) |
|
|
|
est_tok: Math.round(ctxChars / K_RATIO), ctx_chars: charsAccum, ctx_pct: Math.round(charsAccum * 100 / CONTEXT_LIMIT) |
|
|
|
} |
|
|
|
} |
|
|
|
lines.push(JSON.stringify(meta)); try { window.dispatchEvent(new CustomEvent('dshmem:metrics', { detail: JSON.stringify({ accum: accum, delta: delta, chars: ctxChars, est_tok: Math.round(ctxChars / K_RATIO) }) })) } catch (e) {} |
|
|
|
lines.push(JSON.stringify(meta)); try { window.dispatchEvent(new CustomEvent('dshmem:metrics', { detail: JSON.stringify({ accum: accum, delta: delta, chars: ctxChars, est_tok: Math.round(ctxChars / K_RATIO), ctx_chars: charsAccum, ctx_pct: Math.round(charsAccum * 100 / CONTEXT_LIMIT) }) })) } catch (e) { } |
|
|
|
} |
|
|
|
} |
|
|
|
if (!lines.length) return |
|
|
|
if (!lines.length) return |
|
|
|
sendLines(file, lines).then(function (ok) { |
|
|
|
sendLines(file, lines).then(function (ok) { |
|
|
|
|