From 4232f6c5f45ce82985781207b0493e781ef41bf8 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:00:36 +0200 Subject: [PATCH] More null checks for llamacpp logprobs parser --- public/scripts/textgen-settings.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index c4f8d9a0a..44153d05e 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -1039,11 +1039,13 @@ export function parseTextgenLogprobs(token, logprobs) { return { token, topLogprobs: candidates }; } case LLAMACPP: { - /** @type {Record[]} */ if (!logprobs?.length) { return null; } - const candidates = logprobs[0].probs.map(x => [x.tok_str, x.prob]); + const candidates = logprobs?.[0]?.probs?.map(x => [x.tok_str, x.prob]); + if (!candidates) { + return null; + } return { token, topLogprobs: candidates }; } default: