upgraded version

This commit is contained in:
saloui 2023-08-04 10:29:38 +02:00
parent 06f55ce29a
commit 6b650343b5
3 changed files with 43 additions and 3 deletions

View File

@ -175,10 +175,11 @@ class LOLLMSConfig(BaseConfig):
# Check if file already exists in folder
if model_full_path.exists():
print("File already exists in folder")
return False
else:
# Create folder if it doesn't exist
folder_path.mkdir(parents=True, exist_ok=True)
with open(model_full_path,"w") as f:
f.write(path)
print("Reference created, please make sure you don't delete the file or you will have broken link")
ASCIIColors.warning("Reference created, please make sure you don't delete or move the referenced file. This can cause the link to be broken")
return True

View File

@ -7,6 +7,45 @@ from pathlib import Path
import json
import re
import subprocess
import gc
class AdvancedGarbageCollector:
@staticmethod
def hardCollect(obj):
all_referrers = gc.get_referrers(obj)
for referrer in all_referrers:
if not isinstance(referrer, (list, tuple, dict, set)):
referrer = None
del obj
@staticmethod
def safeHardCollect(variable_name, instance=None):
if instance is not None:
if hasattr(instance, variable_name):
obj = getattr(instance, variable_name)
AdvancedGarbageCollector.hardCollect(obj)
else:
print(f"The variable '{variable_name}' does not exist in the instance.")
else:
if variable_name in locals():
obj = locals()[variable_name]
AdvancedGarbageCollector.hardCollect(obj)
elif variable_name in globals():
obj = globals()[variable_name]
AdvancedGarbageCollector.hardCollect(obj)
else:
print(f"The variable '{variable_name}' does not exist in the local or global namespace.")
@staticmethod
def safeHardCollectMultiple(variable_names, instance=None):
for variable_name in variable_names:
AdvancedGarbageCollector.safeHardCollect(variable_name, instance)
@staticmethod
def collect():
gc.collect()
class PackageManager:
@staticmethod
def install_package(package_name):

View File

@ -26,7 +26,7 @@ def get_all_files(path):
setuptools.setup(
name="lollms",
version="2.3.0",
version="2.3.1",
author="Saifeddine ALOUI",
author_email="aloui.saifeddine@gmail.com",
description="A python library for AI personality definition",