Skip to content

Commit

Permalink
Add ctx check and re-order __init__. Closes ggerganov#112
Browse files Browse the repository at this point in the history
  • Loading branch information
abetlen committed Apr 25, 2023
1 parent 996e31d commit cc706fb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,18 @@ def __init__(

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}")

self.ctx = llama_cpp.llama_init_from_file(
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,
Expand Down

0 comments on commit cc706fb

Please sign in to comment.