| 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: |