mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-19 20:57:58 +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
|
||||
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
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user