More null checks for llamacpp logprobs parser

4232f6c5f45ce82985781207b0493e781ef41bf8

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -2Ignore whitespace
public/scripts/textgen-settings.js+4 -2
@@ -1039,11 +1039,13 @@ export function parseTextgenLogprobs(token, logprobs) {
1039 return { token, topLogprobs: candidates };1039 return { token, topLogprobs: candidates };
1040 }1040 }
1041 case LLAMACPP: {1041 case LLAMACPP: {
1042 /** @type {Record<string, number>[]} */
1043 if (!logprobs?.length) {1042 if (!logprobs?.length) {
1044 return null;1043 return null;
1045 }1044 }
1046 const candidates = logprobs[0].probs.map(x => [x.tok_str, x.prob]);1045 const candidates = logprobs?.[0]?.probs?.map(x => [x.tok_str, x.prob]);
1046 if (!candidates) {
1047 return null;
1048 }
1047 return { token, topLogprobs: candidates };1049 return { token, topLogprobs: candidates };
1048 }1050 }
1049 default:1051 default: