Skip to content

Commit 078902a

Browse files
committed
Add llama_grammar_accept_token
1 parent bf90177 commit 078902a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llama_cpp/llama_cpp.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,21 @@ def llama_sample_token(
12621262
_lib.llama_sample_token.restype = llama_token
12631263

12641264

1265+
# /// @details Accepts the sampled token into the grammar
1266+
# LLAMA_API void llama_grammar_accept_token(struct llama_context * ctx, struct llama_grammar * grammar, llama_token token);
1267+
def llama_grammar_accept_token(
1268+
ctx: llama_context_p, grammar: llama_grammar_p, token: llama_token
1269+
):
1270+
return _lib.llama_grammar_accept_token(ctx, grammar, token)
1271+
1272+
1273+
_lib.llama_grammar_accept_token.argtypes = [
1274+
llama_context_p,
1275+
llama_grammar_p,
1276+
llama_token,
1277+
]
1278+
_lib.llama_grammar_accept_token.restype = None
1279+
12651280
# Performance information
12661281

12671282

0 commit comments

Comments
 (0)