mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-18 20:27:58 +00:00
Enhanced
This commit is contained in:
parent
10af0b25f2
commit
1accdb2f27
@ -1,5 +1,5 @@
|
||||
# =================== Lord Of Large Language Models Configuration file ===========================
|
||||
version: 27
|
||||
version: 28
|
||||
binding_name: null
|
||||
model_name: null
|
||||
|
||||
@ -43,6 +43,7 @@ db_path: database.db
|
||||
debug: False
|
||||
auto_update: true
|
||||
auto_save: true
|
||||
auto_title: false
|
||||
# Enables gpu usage
|
||||
enable_gpu: true
|
||||
# Automatically open the browser
|
||||
|
@ -12,7 +12,7 @@ from lollms.config import InstallOption, TypedConfig, BaseConfig
|
||||
from lollms.main_config import LOLLMSConfig
|
||||
from lollms.paths import LollmsPaths
|
||||
from lollms.binding import LLMBinding
|
||||
from lollms.utilities import PromptReshaper
|
||||
from lollms.utilities import PromptReshaper, PackageManager
|
||||
import pkg_resources
|
||||
from pathlib import Path
|
||||
from PIL import Image
|
||||
@ -1576,6 +1576,17 @@ class APScript(StateMachine):
|
||||
if callback:
|
||||
callback(full_text, MSG_TYPE.MSG_TYPE_FULL_INVISIBLE_TO_USER)
|
||||
|
||||
def build_python_code(self, prompt, max_title_length=4096):
|
||||
if not PackageManager.check_package_installed("autopep8"):
|
||||
PackageManager.install_package("autopep8")
|
||||
import autopep8
|
||||
global_prompt = f"{prompt}\n##>Code Builder:```python\n"
|
||||
code = self.fast_gen(global_prompt,max_title_length)
|
||||
code = code.rstrip("`") # Remove trailing backticks
|
||||
formatted_code = autopep8.fix_code(code) # Fix indentation errors
|
||||
return formatted_code
|
||||
|
||||
|
||||
def make_title(self, prompt, max_title_length: int = 50):
|
||||
"""
|
||||
Generates a title for a given prompt.
|
||||
|
@ -23,7 +23,7 @@ from PIL import Image
|
||||
import requests
|
||||
from io import BytesIO
|
||||
import base64
|
||||
|
||||
import importlib
|
||||
|
||||
def load_image(image_file):
|
||||
s_image_file = str(image_file)
|
||||
@ -350,6 +350,26 @@ class PackageManager:
|
||||
import subprocess
|
||||
import sys
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", package_name])
|
||||
|
||||
@staticmethod
|
||||
def check_package_installed(package_name):
|
||||
try:
|
||||
importlib.import_module(package_name)
|
||||
return True
|
||||
except ImportError:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def safe_import(module_name, library_name=None):
|
||||
if not PackageManager.check_package_installed(module_name):
|
||||
print(f"{module_name} module not found. Installing...")
|
||||
if library_name:
|
||||
PackageManager.install_package(library_name)
|
||||
else:
|
||||
PackageManager.install_package(module_name)
|
||||
globals()[module_name] = importlib.import_module(module_name)
|
||||
print(f"{module_name} module imported successfully.")
|
||||
|
||||
|
||||
class GitManager:
|
||||
@staticmethod
|
||||
|
@ -18,3 +18,5 @@ scikit-learn
|
||||
ascii_colors
|
||||
safe_store
|
||||
ascii_colors>=0.1.3
|
||||
|
||||
autopep8
|
||||
|
@ -8,4 +8,6 @@ simple-websocket
|
||||
wget
|
||||
setuptools
|
||||
requests
|
||||
safe_store
|
||||
safe_store
|
||||
|
||||
autopep8
|
Loading…
Reference in New Issue
Block a user