| 2748 | /** @type {(x: { token: string, logprob: number }) => [string, number]} */ | 2748 | /** @type {(x: { token: string, logprob: number }) => [string, number]} */ |
| 2749 | const toTuple = (x) => [x.token, x.logprob]; | 2749 | const toTuple = (x) => [x.token, x.logprob]; |
| 2750 | | 2750 | |
| 2751 | return content.map(({ token, logprob, top_logprobs }) => { | 2751 | return content.map(({ token, logprob, top_logprobs = [] }) => { |
| 2752 | // Add the chosen token to top_logprobs if it's not already there, then | 2752 | // Add the chosen token to top_logprobs if it's not already there, then |
| 2753 | // convert to a list of [token, logprob] pairs | 2753 | // convert to a list of [token, logprob] pairs |
| 2754 | const chosenTopToken = top_logprobs.some((top) => token === top.token); | 2754 | const chosenTopToken = top_logprobs.some((top) => token === top.token); |