UNPKG

node-llama-cpp

Version:

Run AI models locally on your machine with node.js bindings for llama.cpp. Enforce a JSON schema on the model output on the generation level

16 lines 502 B
export function scoreLevels(num, levels) { let res = 0; for (let i = 0; i < levels.length; i++) { const level = levels[i]; const start = level.start; const end = level.end ?? levels[i + 1]?.start ?? Math.max(start, num); if (num < start) break; else if (num >= end) res += level.points; else res += level.points * ((num - start) / (end - start)); } return res; } //# sourceMappingURL=scoreLevels.js.map