| 1046 | // 3 cases: | 1046 | // 3 cases: |
| 1047 | // 1. Before commit 6c5bc06, "probs" key with "tok_str"/"prob", and probs are [0, 1] so use them directly. | 1047 | // 1. Before commit 6c5bc06, "probs" key with "tok_str"/"prob", and probs are [0, 1] so use them directly. |
| 1048 | // 2. After commit 6c5bc06 but before commit 89d604f broke logprobs (they all return the first token's logprobs) | 1048 | // 2. After commit 6c5bc06 but before commit 89d604f broke logprobs (they all return the first token's logprobs) |
| 1049 | // We don't know the client version so we can't do much about this. | 1049 | // We don't know the llama.cpp version so we can't do much about this. |
| 1050 | // 3. After commit 89d604f uses OpenAI-compatible format with "completion_probabilities" and "token"/"logprob" keys. | 1050 | // 3. After commit 89d604f uses OpenAI-compatible format with "completion_probabilities" and "token"/"logprob" keys. |
| 1051 | // Note that it is also the *actual* logprob (negative number), so we need to convert to [0, 1]. | 1051 | // Note that it is also the *actual* logprob (negative number), so we need to convert to [0, 1]. |
| 1052 | if (logprobs?.[0]?.probs) { | 1052 | if (logprobs?.[0]?.probs) { |