mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-02-06 10:59:23 +00:00
repared tool
This commit is contained in:
parent
60f5360bc7
commit
ab7d51458b
@ -484,9 +484,12 @@ class LoLLMsAPPI():
|
|||||||
self._message_id = 0
|
self._message_id = 0
|
||||||
|
|
||||||
self.db_path = config["db_path"]
|
self.db_path = config["db_path"]
|
||||||
|
if Path(self.db_path).is_absolute():
|
||||||
# Create database object
|
# Create database object
|
||||||
self.db = DiscussionsDB(self.db_path)
|
self.db = DiscussionsDB(self.db_path)
|
||||||
|
else:
|
||||||
|
# Create database object
|
||||||
|
self.db = DiscussionsDB(self.lollms_paths.personal_path/"databases"/self.db_path)
|
||||||
|
|
||||||
# If the database is empty, populate it with tables
|
# If the database is empty, populate it with tables
|
||||||
self.db.populate()
|
self.db.populate()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
from pathlib import Path
|
||||||
__author__ = "parisneo"
|
__author__ = "parisneo"
|
||||||
__github__ = "https://github.com/ParisNeo/lollms-webui"
|
__github__ = "https://github.com/ParisNeo/lollms-webui"
|
||||||
__copyright__ = "Copyright 2023, "
|
__copyright__ = "Copyright 2023, "
|
||||||
@ -13,7 +13,8 @@ class DiscussionsDB:
|
|||||||
MSG_TYPE_CONDITIONNING = 1
|
MSG_TYPE_CONDITIONNING = 1
|
||||||
|
|
||||||
def __init__(self, db_path="database.db"):
|
def __init__(self, db_path="database.db"):
|
||||||
self.db_path = db_path
|
self.db_path = Path(db_path)
|
||||||
|
self.db_path .parent.mkdir(exist_ok=True, parents= True)
|
||||||
|
|
||||||
def populate(self):
|
def populate(self):
|
||||||
"""
|
"""
|
||||||
|
26
app.py
26
app.py
@ -25,7 +25,7 @@ from tqdm import tqdm
|
|||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import signal
|
||||||
from lollms.personality import AIPersonality, MSG_TYPE
|
from lollms.personality import AIPersonality, MSG_TYPE
|
||||||
from lollms.helpers import ASCIIColors
|
from lollms.helpers import ASCIIColors, BaseConfig
|
||||||
from lollms.paths import LollmsPaths
|
from lollms.paths import LollmsPaths
|
||||||
from api.db import DiscussionsDB, Discussion
|
from api.db import DiscussionsDB, Discussion
|
||||||
from api.helpers import compare_lists
|
from api.helpers import compare_lists
|
||||||
@ -87,6 +87,12 @@ class LoLLMsWebUI(LoLLMsAPPI):
|
|||||||
# =========================================================================================
|
# =========================================================================================
|
||||||
# Endpoints
|
# Endpoints
|
||||||
# =========================================================================================
|
# =========================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
self.add_endpoint("/switch_personal_path", "switch_personal_path", self.switch_personal_path, methods=["POST"])
|
||||||
|
|
||||||
self.add_endpoint("/add_reference_to_local_model", "add_reference_to_local_model", self.add_reference_to_local_model, methods=["POST"])
|
self.add_endpoint("/add_reference_to_local_model", "add_reference_to_local_model", self.add_reference_to_local_model, methods=["POST"])
|
||||||
|
|
||||||
self.add_endpoint("/send_file", "send_file", self.send_file, methods=["POST"])
|
self.add_endpoint("/send_file", "send_file", self.send_file, methods=["POST"])
|
||||||
@ -689,6 +695,22 @@ class LoLLMsWebUI(LoLLMsAPPI):
|
|||||||
self.process.cancel_generation()
|
self.process.cancel_generation()
|
||||||
return jsonify({"status": True})
|
return jsonify({"status": True})
|
||||||
|
|
||||||
|
|
||||||
|
def switch_personal_path(self):
|
||||||
|
data = request.get_json()
|
||||||
|
path = data["path"]
|
||||||
|
global_paths_cfg = Path("./global_paths_cfg.yaml")
|
||||||
|
if global_paths_cfg.exists():
|
||||||
|
try:
|
||||||
|
cfg = BaseConfig()
|
||||||
|
cfg.load_config(global_paths_cfg)
|
||||||
|
cfg.lollms_personal_path = path
|
||||||
|
cfg.save_config(global_paths_cfg)
|
||||||
|
return jsonify({"status": True})
|
||||||
|
except Exception as ex:
|
||||||
|
print(ex)
|
||||||
|
return jsonify({"status": False, 'error':f"Couldn't switch path: {ex}"})
|
||||||
|
|
||||||
def add_reference_to_local_model(self):
|
def add_reference_to_local_model(self):
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
path = data["path"]
|
path = data["path"]
|
||||||
@ -1087,6 +1109,8 @@ def sync_cfg(default_config, config):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
lollms_paths = LollmsPaths.find_paths(force_local=True)
|
lollms_paths = LollmsPaths.find_paths(force_local=True)
|
||||||
|
db_folder = lollms_paths.personal_path/"databases"
|
||||||
|
db_folder.mkdir(parents=True, exist_ok=True)
|
||||||
parser = argparse.ArgumentParser(description="Start the chatbot Flask app.")
|
parser = argparse.ArgumentParser(description="Start the chatbot Flask app.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c", "--config", type=str, default="local_config", help="Sets the configuration file to be used."
|
"-c", "--config", type=str, default="local_config", help="Sets the configuration file to be used."
|
||||||
|
@ -28,4 +28,4 @@ user_name: user
|
|||||||
|
|
||||||
# UI parameters
|
# UI parameters
|
||||||
debug: False
|
debug: False
|
||||||
db_path: databases/database.db
|
db_path: database.db
|
Loading…
x
Reference in New Issue
Block a user