Skip to content

Commit cc706fb

Browse files
committed
Add ctx check and re-order __init__. Closes ggml-org#112
1 parent 996e31d commit cc706fb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llama_cpp/llama.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ def __init__(
133133

134134
self.n_threads = n_threads or max(multiprocessing.cpu_count() // 2, 1)
135135

136+
self.lora_base = lora_base
137+
self.lora_path = lora_path
138+
136139
if not os.path.exists(model_path):
137140
raise ValueError(f"Model path does not exist: {model_path}")
138141

139142
self.ctx = llama_cpp.llama_init_from_file(
140143
self.model_path.encode("utf-8"), self.params
141144
)
142145

143-
self.lora_base = lora_base
144-
self.lora_path = lora_path
146+
assert self.ctx is not None
147+
145148
if self.lora_path:
146149
if llama_cpp.llama_apply_lora_from_file(
147150
self.ctx,

0 commit comments

Comments
 (0)