mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-20 21:23:17 +00:00
Merge branch 'main' of https://github.com/ParisNeo/lollms
This commit is contained in:
commit
88651def4a
4
.gitignore
vendored
4
.gitignore
vendored
@ -178,4 +178,6 @@ temp
|
||||
outputs
|
||||
|
||||
# Global path configuration
|
||||
global_paths_cfg.yaml
|
||||
global_paths_cfg.yaml
|
||||
|
||||
.vscode
|
38
docs/LLMBinding_doc.md
Normal file
38
docs/LLMBinding_doc.md
Normal file
@ -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.
|
14
docs/index.html
Normal file
14
docs/index.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome to LOLLMs documentation</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to LOLLMs documentation</h1>
|
||||
<ul>
|
||||
<li><a href="LLMBinding_doc.html">LLMBinding Documentation</a></li>
|
||||
<li><a href="Lollms-server.html">LOLLMS Server Documentation</a></li>
|
||||
<li><a href="server_endpoints.html">Server Endpoints Documentation</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
@ -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)
|
||||
|
@ -5,4 +5,6 @@ flask
|
||||
flask_socketio
|
||||
flask-cors
|
||||
simple-websocket
|
||||
eventlet
|
||||
eventlet
|
||||
wget
|
||||
setuptools
|
@ -4,4 +4,6 @@ Pillow
|
||||
flask
|
||||
flask_socketio
|
||||
flask-cors
|
||||
simple-websocket
|
||||
simple-websocket
|
||||
wget
|
||||
setuptools
|
4
setup.py
4
setup.py
@ -26,7 +26,7 @@ def get_all_files(path):
|
||||
|
||||
setuptools.setup(
|
||||
name="lollms",
|
||||
version="2.0.28",
|
||||
version="2.0.32",
|
||||
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",
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user