diff --git a/examples/server/public/index.html b/examples/server/public/index.html index ff17c8a18..740154262 100644 --- a/examples/server/public/index.html +++ b/examples/server/public/index.html @@ -404,7 +404,46 @@ ` } - const Probabilites = (params) => { /* Not implemented yet */ } + const probColor = (p) => { + const r = Math.floor(192 * (1 - p)); + const g = Math.floor(192 * p); + return `rgba(${r},${g},0,0.75)`; + } + + const Probabilites = (params) => { + return params.data.map(msg => { + const { completion_probabilities } = msg; + + let pColor = 'transparent'; + if (completion_probabilities.length === 1) { + const { probs } = completion_probabilities[0] + const found = probs.find(p => p.tok_str === msg.content) + pColor = probColor(found ? found.prob : 0) + } + + const popoverChildren = html` +