From cc706fb94448f7d9c0db89eebd7188d738c6831d Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Tue, 25 Apr 2023 09:00:53 -0400 Subject: [PATCH] Add ctx check and re-order __init__. Closes #112 --- llama_cpp/llama.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llama_cpp/llama.py b/llama_cpp/llama.py index 487f44d..df9a491 100644 --- a/llama_cpp/llama.py +++ b/llama_cpp/llama.py @@ -133,6 +133,9 @@ class Llama: self.n_threads = n_threads or max(multiprocessing.cpu_count() // 2, 1) + self.lora_base = lora_base + self.lora_path = lora_path + if not os.path.exists(model_path): raise ValueError(f"Model path does not exist: {model_path}") @@ -140,8 +143,8 @@ class Llama: self.model_path.encode("utf-8"), self.params ) - self.lora_base = lora_base - self.lora_path = lora_path + assert self.ctx is not None + if self.lora_path: if llama_cpp.llama_apply_lora_from_file( self.ctx,