This commit is contained in:
Saifeddine ALOUI 2023-11-26 02:32:24 +01:00
parent 10af0b25f2
commit 1accdb2f27
6 changed files with 41 additions and 5 deletions

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -18,3 +18,5 @@ scikit-learn
ascii_colors
safe_store
ascii_colors>=0.1.3
autopep8

View File

@ -8,4 +8,6 @@ simple-websocket
wget
setuptools
requests
safe_store
safe_store
autopep8

View File

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