Skip to content

Commit 39704ec

Browse files
committed
bump llama_tokenize API to latest specs
1 parent 8d75016 commit 39704ec

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

llama_cpp/llama_cpp.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,14 +956,22 @@ def llama_token_nl(ctx: llama_context_p) -> llama_token:
956956
def llama_tokenize(
957957
ctx: llama_context_p,
958958
text: bytes,
959+
text_len: Union[c_int, int],
959960
tokens, # type: Array[llama_token]
960961
n_max_tokens: Union[c_int, int],
961962
add_bos: Union[c_bool, int],
962963
) -> int:
963-
return _lib.llama_tokenize(ctx, text, tokens, n_max_tokens, add_bos)
964+
return _lib.llama_tokenize(ctx, text, text_len, tokens, n_max_tokens, add_bos)
964965

965966

966-
_lib.llama_tokenize.argtypes = [llama_context_p, c_char_p, llama_token_p, c_int, c_bool]
967+
_lib.llama_tokenize.argtypes = [
968+
llama_context_p,
969+
c_char_p,
970+
c_int,
971+
llama_token_p,
972+
c_int,
973+
c_bool,
974+
]
967975
_lib.llama_tokenize.restype = c_int
968976

969977

@@ -976,16 +984,18 @@ def llama_tokenize(
976984
def llama_tokenize_with_model(
977985
model: llama_model_p,
978986
text: bytes,
987+
text_len: Union[c_int, int],
979988
tokens, # type: Array[llama_token]
980989
n_max_tokens: Union[c_int, int],
981990
add_bos: Union[c_bool, bool],
982991
) -> int:
983-
return _lib.llama_tokenize_with_model(model, text, tokens, n_max_tokens, add_bos)
992+
return _lib.llama_tokenize_with_model(model, text, text_len, tokens, n_max_tokens, add_bos)
984993

985994

986995
_lib.llama_tokenize_with_model.argtypes = [
987996
llama_model_p,
988997
c_char_p,
998+
c_int,
989999
llama_token_p,
9901000
c_int,
9911001
c_bool,

0 commit comments

Comments
 (0)