File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1655,14 +1655,21 @@ def create_chat_completion(
16551655 )
16561656 return self ._convert_completion_to_chat (completion_or_chunks , stream = stream ) # type: ignore
16571657
1658- def __del__ (self ):
1658+ def _free_model (self ):
16591659 if hasattr (self , "model" ) and self .model is not None :
16601660 llama_cpp .llama_free_model (self .model )
16611661 self .model = None
16621662 if hasattr (self , "ctx" ) and self .ctx is not None :
16631663 llama_cpp .llama_free (self .ctx )
16641664 self .ctx = None
16651665
1666+ def __del__ (self ):
1667+ if self .verbose :
1668+ self ._free_model ()
1669+ else :
1670+ with suppress_stdout_stderr ():
1671+ self ._free_model ()
1672+
16661673 def __getstate__ (self ):
16671674 return dict (
16681675 model_path = self .model_path ,
You can’t perform that action at this time.
0 commit comments