From 5d71c4dff885100d20110ba38b4cca577fb89445 Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 29 Jun 2023 11:26:57 +0200 Subject: [PATCH 1/6] added documentation --- doc/LLMBinding_doc.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 doc/LLMBinding_doc.md diff --git a/doc/LLMBinding_doc.md b/doc/LLMBinding_doc.md new file mode 100644 index 0000000..5987dd7 --- /dev/null +++ b/doc/LLMBinding_doc.md @@ -0,0 +1,38 @@ +# LLMBinding + +The LLMBinding class is an interface class that serves as a template for implementing bindings with different large language models (LLMs) frameworks. It provides a set of methods that need to be implemented by specific bindings to enable interaction with LLMs. + +Here's a breakdown of the important components and methods in the LLMBinding class: + +1. **Constructor (`__init__`):** + - Parameters: + - `binding_dir` (Path): The path to the binding directory. + - `lollms_paths` (LollmsPaths): An instance of the LollmsPaths class that provides paths to different directories. + - `config` (LOLLMSConfig): The global configuration object for LOLLMS. + - `binding_config` (TypedConfig): The configuration object specific to the binding. + - `installation_option` (InstallOption, optional): The installation option for the binding. Defaults to `InstallOption.INSTALL_IF_NECESSARY`. + - `file_extension` (str, optional): The file extension for models supported by the binding. Defaults to `"*.bin"`. + - Description: The constructor initializes the LLMBinding object and sets up various properties based on the provided parameters. It also handles the installation of the binding if necessary. + +2. **Installation Methods:** + - `install()`: This method handles the installation procedure for the binding and should be implemented by each specific binding. It can perform tasks like downloading and installing the necessary dependencies or models. This method is called during object initialization if the binding is not already installed or if the installation is forced. + +3. **Model Methods:** + - `build_model()`: This method is responsible for constructing the model specific to the binding. It needs to be implemented by each binding and should return the constructed model object. + - `get_model_path()`: This method retrieves the path of the model based on the configuration. It handles different scenarios, such as reading the model path from a file or constructing it based on the configuration. + +4. **Text Generation Methods:** + - `generate(prompt, n_predict, callback, verbose, **gpt_params)`: This method generates text based on the provided prompt using the LLM model. It should be implemented by each binding and handle the generation process specific to the underlying LLM framework. + - `tokenize(prompt)`: This method tokenizes the given prompt using the model's tokenizer. It needs to be implemented to provide tokenization functionality. + - `detokenize(tokens_list)`: This method detokenizes the given list of tokens using the model's tokenizer. It should be implemented to provide detokenization functionality. + +5. **Utility Methods:** + - `load_binding_config()`: This method loads the content of the binding's local configuration file. It reads the configuration data and syncs it with the binding_config object. + - `save_config_file(path)`: This method saves the binding's configuration file to the specified path. + - `list_models(config)`: This method lists the available models for the binding. It should return a list of model names that match the specified file extension. + +The LLMBinding class also includes a few other utility methods, such as `get_current_seed()` and `reinstall_pytorch_with_cuda()`, which provide additional functionality specific to the LOLLMS tool. + +To create a new binding for a different LLM framework, you need to subclass the LLMBinding class and implement the required methods based on the framework's API and functionality. Each method should be customized to work with the specific LLM framework you're integrating. + +Additionally, there are two builder classes, `BindingBuilder` and `ModelBuilder`, provided for convenience. These classes assist in building LLMBinding objects and LLM models, respectively. From 4201168c219086b071221c222ceb4013457be891 Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 29 Jun 2023 11:33:09 +0200 Subject: [PATCH 2/6] changed requirements --- lollms/main_config.py | 4 ++-- setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lollms/main_config.py b/lollms/main_config.py index 90debaf..9d2ff05 100644 --- a/lollms/main_config.py +++ b/lollms/main_config.py @@ -8,7 +8,7 @@ from lollms.paths import LollmsPaths from lollms.config import BaseConfig #from lollms.binding import LLMBinding import shutil -import urllib +import urllib.request as rq from tqdm import tqdm from pathlib import Path @@ -160,7 +160,7 @@ class LOLLMSConfig(BaseConfig): progress_bar.update(block_size) # Download file from URL to folder try: - urllib.request.urlretrieve(url, folder_path / url.split("/")[-1], reporthook=report_progress if callback is None else callback) + rq.urlretrieve(url, folder_path / url.split("/")[-1], reporthook=report_progress if callback is None else callback) print("File downloaded successfully!") except Exception as e: print("Error downloading file:", e) diff --git a/setup.py b/setup.py index f793957..15fea16 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="2.0.27", + version="2.0.30", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition", @@ -45,7 +45,7 @@ setuptools.setup( }, extras_require={"dev": requirements_dev}, classifiers=[ - "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.10", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", ], From 776eee5c53b608f1bf5a6610fa3e717c427bfa04 Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 29 Jun 2023 11:40:09 +0200 Subject: [PATCH 3/6] updated requirements --- .gitignore | 4 +++- requirements.txt | 3 ++- requirements_dev.txt | 3 ++- setup.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index bbb090c..f550a5a 100644 --- a/.gitignore +++ b/.gitignore @@ -178,4 +178,6 @@ temp outputs # Global path configuration -global_paths_cfg.yaml \ No newline at end of file +global_paths_cfg.yaml + +.vscode \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2860a64..2ef119f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ flask flask_socketio flask-cors simple-websocket -eventlet \ No newline at end of file +eventlet +wget \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt index 5ff395b..7130e38 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -4,4 +4,5 @@ Pillow flask flask_socketio flask-cors -simple-websocket \ No newline at end of file +simple-websocket +wget \ No newline at end of file diff --git a/setup.py b/setup.py index 15fea16..1254f2f 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="2.0.30", + version="2.0.31", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition", From 3efab4c8d4ab839835d50000f8ee7ddf232165a7 Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 29 Jun 2023 11:41:34 +0200 Subject: [PATCH 4/6] renamed doc to docs --- {doc => docs}/LLMBinding_doc.md | 0 {doc => docs}/Lollms-server.md | 0 {doc => docs}/server_endpoints.md | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {doc => docs}/LLMBinding_doc.md (100%) rename {doc => docs}/Lollms-server.md (100%) rename {doc => docs}/server_endpoints.md (100%) diff --git a/doc/LLMBinding_doc.md b/docs/LLMBinding_doc.md similarity index 100% rename from doc/LLMBinding_doc.md rename to docs/LLMBinding_doc.md diff --git a/doc/Lollms-server.md b/docs/Lollms-server.md similarity index 100% rename from doc/Lollms-server.md rename to docs/Lollms-server.md diff --git a/doc/server_endpoints.md b/docs/server_endpoints.md similarity index 100% rename from doc/server_endpoints.md rename to docs/server_endpoints.md From 7eaba04b1573c3d7b61389e3b90e6045e9fecb55 Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 29 Jun 2023 14:44:55 +0200 Subject: [PATCH 5/6] updated --- docs/index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docs/index.html diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..166875d --- /dev/null +++ b/docs/index.html @@ -0,0 +1,14 @@ + + + + Welcome to LOLLMs documentation + + +

Welcome to LOLLMs documentation

+ + + From 1a83053fbfdebdf29ee89a410fde12b16752050f Mon Sep 17 00:00:00 2001 From: saloui Date: Thu, 29 Jun 2023 16:49:57 +0200 Subject: [PATCH 6/6] added setuptools requirements --- requirements.txt | 3 ++- requirements_dev.txt | 3 ++- setup.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2ef119f..e6d73bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ flask_socketio flask-cors simple-websocket eventlet -wget \ No newline at end of file +wget +setuptools \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt index 7130e38..92511d3 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -5,4 +5,5 @@ flask flask_socketio flask-cors simple-websocket -wget \ No newline at end of file +wget +setuptools \ No newline at end of file diff --git a/setup.py b/setup.py index 1254f2f..24b731c 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="2.0.31", + version="2.0.32", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition",