mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-24 06:46:40 +00:00
upgraded version
This commit is contained in:
parent
06f55ce29a
commit
6b650343b5
@ -175,10 +175,11 @@ class LOLLMSConfig(BaseConfig):
|
|||||||
# Check if file already exists in folder
|
# Check if file already exists in folder
|
||||||
if model_full_path.exists():
|
if model_full_path.exists():
|
||||||
print("File already exists in folder")
|
print("File already exists in folder")
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
# Create folder if it doesn't exist
|
# Create folder if it doesn't exist
|
||||||
folder_path.mkdir(parents=True, exist_ok=True)
|
folder_path.mkdir(parents=True, exist_ok=True)
|
||||||
with open(model_full_path,"w") as f:
|
with open(model_full_path,"w") as f:
|
||||||
f.write(path)
|
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
|
||||||
|
@ -7,6 +7,45 @@ from pathlib import Path
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import subprocess
|
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:
|
class PackageManager:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def install_package(package_name):
|
def install_package(package_name):
|
||||||
|
2
setup.py
2
setup.py
@ -26,7 +26,7 @@ def get_all_files(path):
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="lollms",
|
name="lollms",
|
||||||
version="2.3.0",
|
version="2.3.1",
|
||||||
author="Saifeddine ALOUI",
|
author="Saifeddine ALOUI",
|
||||||
author_email="aloui.saifeddine@gmail.com",
|
author_email="aloui.saifeddine@gmail.com",
|
||||||
description="A python library for AI personality definition",
|
description="A python library for AI personality definition",
|
||||||
|
Loading…
Reference in New Issue
Block a user