@@ -973,48 +973,43 @@ def llama_tokenize_with_model(
973973_lib .llama_tokenize_with_model .restype = c_int
974974
975975
976- # // Token Id -> String. Uses the vocabulary in the provided context
977- # // Does not write null terminator to the buffer
978- # LLAMA_API int llama_token_to_str(
976+ # // Token Id -> Piece.
977+ # // Uses the vocabulary in the provided context.
978+ # // Does not write null terminator to the buffer.
979+ # // User code is responsible to remove the leading whitespace of the first non-BOS token when decoding multiple tokens.
980+ # LLAMA_API int llama_token_to_piece(
979981# const struct llama_context * ctx,
980- # llama_token token,
981- # char * buf,
982- # int length);
983- def llama_token_to_str (
982+ # llama_token token,
983+ # char * buf,
984+ # int length);
985+ def llama_token_to_piece (
984986 ctx : llama_context_p , token : llama_token , buf : bytes , length : c_int
985987) -> int :
986- return _lib .llama_token_to_str (ctx , token , buf , length )
988+ return _lib .llama_token_to_piece (ctx , token , buf , length )
987989
988990
989- _lib .llama_tokenize_with_model .argtypes = [
990- llama_model_p ,
991- c_char_p ,
992- llama_token_p ,
993- c_int ,
994- c_bool ,
995- ]
996- _lib .llama_tokenize_with_model .restype = c_int
991+ _lib .llama_token_to_piece .argtypes = [llama_context_p , llama_token , c_char_p , c_int ]
992+ _lib .llama_token_to_piece .restype = c_int
997993
998994
999- # LLAMA_API int llama_token_to_str_with_model (
1000- # const struct llama_model * model,
1001- # llama_token token,
1002- # char * buf,
1003- # int length);
1004- def llama_token_to_str_with_model (
995+ # LLAMA_API int llama_token_to_piece_with_model (
996+ # const struct llama_model * model,
997+ # llama_token token,
998+ # char * buf,
999+ # int length);
1000+ def llama_token_to_piece_with_model (
10051001 model : llama_model_p , token : llama_token , buf : bytes , length : c_int
10061002) -> int :
1007- return _lib .llama_token_to_str_with_model (model , token , buf , length )
1003+ return _lib .llama_token_to_piece_with_model (model , token , buf , length )
10081004
10091005
1010- _lib .llama_token_to_str_with_model .argtypes = [
1006+ _lib .llama_token_to_piece_with_model .argtypes = [
10111007 llama_model_p ,
10121008 llama_token ,
10131009 c_char_p ,
10141010 c_int ,
10151011]
1016- _lib .llama_token_to_str_with_model .restype = c_int
1017-
1012+ _lib .llama_token_to_piece_with_model .restype = c_int
10181013
10191014# //
10201015# // Grammar
0 commit comments