Skip to content

Commit

Permalink
Assistant destructor
Browse files Browse the repository at this point in the history
  • Loading branch information
artitw committed Oct 7, 2024
1 parent c8e8094 commit c58ff8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="text2text",
version="1.7.1",
version="1.7.2",
author="artitw",
author_email="artitw@gmail.com",
description="Text2Text: Crosslingual NLP/G toolkit",
Expand Down
14 changes: 9 additions & 5 deletions text2text/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ def __init__(self, **kwargs):
self.structured_client = Ollama(model=self.model_name, request_timeout=120.0)

def __del__(self):
ollama.delete(self.model_name)
if self.ollama_serve_proc:
self.ollama_serve_proc.kill()
self.ollama_serve_proc = None
try:
if ollama_version():
ollama.delete(self.model_name)
if self.ollama_serve_proc:
self.ollama_serve_proc.kill()
self.ollama_serve_proc = None
except Exception as e:
warnings.warn(str(e))

def load_model(self):
if not ollama_version():
self.__del__(self)
self.__del__()

return_code = os.system("sudo apt install -q -y lshw")
if return_code != 0:
Expand Down

0 comments on commit c58ff8f

Please sign in to comment.