llamaTokenToPiece method
Get string representation of the token.
Implementation
String llamaTokenToPiece(Pointer<llama_context> ctx, int token) {
final buffer = malloc.allocate<Char>(8);
for (var i = 0; i < 8; ++i) {
buffer[i] = 0;
}
final model = llama_get_model(ctx);
llama_token_to_piece(model, token, buffer, 8);
try {
return buffer.cast<Utf8>().toDartString();
} on FormatException {
return '';
} finally {
malloc.free(buffer);
}
}