Skip to content

Commit 3d454a7

Browse files
committed
Add update_input_tokens to pyllama
1 parent b29d987 commit 3d454a7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/PyLlama.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class PyLLAMA {
4646
void update_input(const std::string& text) {
4747
llama_update_input(*ctx_ptr, text);
4848
}
49+
void update_input_tokens(const std::vector<gpt_vocab::id>& ids) {
50+
llama_update_input(*ctx_ptr, ids);
51+
}
4952
bool is_finished() {
5053
return llama_context_is_finished(*ctx_ptr);
5154
}
@@ -146,7 +149,8 @@ PYBIND11_MODULE(llamacpp, m) {
146149
.def(py::init<gpt_params>())
147150
.def("prepare_context", &PyLLAMA::prepare_context, "Prepare the LLaMA context")
148151
.def("add_bos", &PyLLAMA::add_bos, "Add a BOS token to the input")
149-
.def("update_input", &PyLLAMA::update_input, "Update input")
152+
.def("update_input", &PyLLAMA::update_input, "Update input as text")
153+
.def("update_input_tokens", &PyLLAMA::update_input_tokens, "Update input tokens")
150154
.def("is_finished", &PyLLAMA::is_finished, "Check if the model is finished")
151155
.def("has_unconsumed_input", &PyLLAMA::has_unconsumed_input, "Check if the model has unconsumed input")
152156
// ingest_all_pending_input. Does not print to stdout by default

0 commit comments

Comments
 (0)