diff --git a/tools/completion/completion.cpp b/tools/completion/completion.cpp index f368a2f4c6..7f8da2a59d 100644 --- a/tools/completion/completion.cpp +++ b/tools/completion/completion.cpp @@ -143,12 +143,13 @@ int main(int argc, char ** argv) { ctx = llama_init->context(); model = llama_init->model(); - smpl = llama_init->sampler(0); - if (ctx == NULL) { - LOG_ERR("%s: error: unable to create context\n", __func__); + if (model == nullptr || ctx == nullptr) { + LOG_ERR("%s : failed to init\n", __func__); return 1; } + + smpl = llama_init->sampler(0); llama_memory_t mem = llama_get_memory(ctx); const llama_vocab * vocab = llama_model_get_vocab(model);