convert the token to a string
| 967 | |
| 968 | // convert the token to a string |
| 969 | static int convert_token_to_string(const llama_vocab * vocab, const llama_token token_id, std::string & piece) { |
| 970 | char buf[256]; |
| 971 | int n = llama_token_to_piece(vocab, token_id, buf, sizeof(buf), 0, true); |
| 972 | if (n < 0) { |
| 973 | printe("failed to convert token to piece\n"); |
| 974 | return 1; |
| 975 | } |
| 976 | |
| 977 | piece = std::string(buf, n); |
| 978 | return 0; |
| 979 | } |
| 980 | |
| 981 | static void print_word_and_concatenate_to_response(const std::string & piece, std::string & response) { |
| 982 | printf("%s", piece.c_str()); |
no test coverage detected