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(
1655
1655
)
1656
1656
return self ._convert_completion_to_chat (completion_or_chunks , stream = stream ) # type: ignore
1657
1657
1658
- def __del__ (self ):
1658
+ def _free_model (self ):
1659
1659
if hasattr (self , "model" ) and self .model is not None :
1660
1660
llama_cpp .llama_free_model (self .model )
1661
1661
self .model = None
1662
1662
if hasattr (self , "ctx" ) and self .ctx is not None :
1663
1663
llama_cpp .llama_free (self .ctx )
1664
1664
self .ctx = None
1665
1665
1666
+ def __del__ (self ):
1667
+ if self .verbose :
1668
+ self ._free_model ()
1669
+ else :
1670
+ with suppress_stdout_stderr ():
1671
+ self ._free_model ()
1672
+
1666
1673
def __getstate__ (self ):
1667
1674
return dict (
1668
1675
model_path = self .model_path ,
You can’t perform that action at this time.
0 commit comments