LLModel objects should hold a reference to the library

prevents llmodel lib from being gc'd before live model objects
This commit is contained in:
Aaron Miller 2023-07-13 18:24:25 -04:00 committed by AT
parent 1c4a244291
commit c77ab849c0

View File

@ -154,10 +154,11 @@ class LLModel:
self.model = None self.model = None
self.model_name = None self.model_name = None
self.context = None self.context = None
self.llmodel_lib = llmodel
def __del__(self): def __del__(self):
if self.model is not None: if self.model is not None:
llmodel.llmodel_model_destroy(self.model) self.llmodel_lib.llmodel_model_destroy(self.model)
def memory_needed(self, model_path: str) -> int: def memory_needed(self, model_path: str) -> int:
model_path_enc = model_path.encode("utf-8") model_path_enc = model_path.encode("utf-8")