Fixed crash when top_logprobs is empty. (#4680) Co-authored-by: user <user@exmaple.com>
Signed| @@ -2748,7 +2748,7 @@ function parseOpenAIChatLogprobs(logprobs) { | ||
| 2748 | 2748 | /** @type {(x: { token: string, logprob: number }) => [string, number]} */ |
| 2749 | 2749 | const toTuple = (x) => [x.token, x.logprob]; |
| 2750 | 2750 | |
| 2751 | 2751 | return content.map(({ token, logprob, top_logprobs = [] }) => { |
| 2752 | 2752 | // Add the chosen token to top_logprobs if it's not already there, then |
| 2753 | 2753 | // convert to a list of [token, logprob] pairs |
| 2754 | 2754 | const chosenTopToken = top_logprobs.some((top) => token === top.token); |