From 6943bab6d817bf71927642ab29e25b94a01fd22c Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Wed, 14 Feb 2024 03:38:41 -0500 Subject: [PATCH] fix: destructor exception where internal classes are missing some uninitialized attributes --- llama_cpp/_internals.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llama_cpp/_internals.py b/llama_cpp/_internals.py index 3a71ef0..9473d35 100644 --- a/llama_cpp/_internals.py +++ b/llama_cpp/_internals.py @@ -42,6 +42,8 @@ class _LlamaModel: self._llama_free_model = llama_cpp._lib.llama_free_model # type: ignore + self.model = None + if not os.path.exists(path_model): raise ValueError(f"Model path does not exist: {path_model}") @@ -248,6 +250,7 @@ class _LlamaContext: self.verbose = verbose self._llama_free = llama_cpp._lib.llama_free # type: ignore + self.ctx = None assert self.model.model is not None @@ -497,6 +500,7 @@ class _LlamaBatch: self._llama_batch_free = llama_cpp._lib.llama_batch_free # type: ignore + self.batch = None self.batch = llama_cpp.llama_batch_init( self.n_tokens, self.embd, self.n_seq_max )