| 696 | } |
| 697 | |
| 698 | std::string common_sampler_prev_str(common_sampler * gsmpl, llama_context * ctx_main, int n) { |
| 699 | n = std::min(n, (int) gsmpl->prev.size()); |
| 700 | |
| 701 | if (n <= 0) { |
| 702 | return ""; |
| 703 | } |
| 704 | |
| 705 | std::string result; |
| 706 | result.reserve(8*n); // 8 is the average length of a token [citation needed], TODO: compute this from the vocab |
| 707 | |
| 708 | for (int i = n - 1; i >= 0; i--) { |
| 709 | const llama_token id = gsmpl->prev.rat(i); |
| 710 | |
| 711 | GGML_ASSERT(id != LLAMA_TOKEN_NULL && "null token in the sampling history - should not happen"); |
| 712 | |
| 713 | result += common_token_to_piece(ctx_main, id); |
| 714 | } |
| 715 | |
| 716 | return result; |
| 717 | } |
| 718 | |
| 719 | char common_sampler_type_to_chr(enum common_sampler_type cnstr) { |
| 720 | switch (cnstr) { |
no test coverage detected