From eddb3b68b7bef6a219f9b4a6b3cf7fd53b0b037e Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sun, 17 Mar 2024 17:56:00 +0100 Subject: [PATCH] fixed bugs --- lollms/binding.py | 1 - lollms/databases/skills_database.py | 14 +++++++++++++- .../server/endpoints/lollms_skills_library.py | 17 +++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lollms/binding.py b/lollms/binding.py index a5c5e44..2a2a915 100644 --- a/lollms/binding.py +++ b/lollms/binding.py @@ -247,7 +247,6 @@ class LLMBinding: def install_model(self, model_type:str, model_path:str, variant_name:str, client_id:int=None): print("Install model triggered") - sanitize_path(model_path) model_path = model_path.replace("\\","/") parts = model_path.split("/") if parts[2]=="huggingface.co": diff --git a/lollms/databases/skills_database.py b/lollms/databases/skills_database.py index 9043072..4e24cd8 100644 --- a/lollms/databases/skills_database.py +++ b/lollms/databases/skills_database.py @@ -177,7 +177,19 @@ class SkillsLibrary: return list(set([r[0] for r in res])) - def get_titles(self, category): + def get_titles(self): + conn = sqlite3.connect(self.db_path) + cursor = conn.cursor() + # Use direct string concatenation for the MATCH expression. + # Ensure text is safely escaped to avoid SQL injection. + query = "SELECT id, title FROM skills_library" + cursor.execute(query) + res = cursor.fetchall() + cursor.close() + conn.close() + return [{"id":r[0], "title":r[1]} for r in res] + + def get_titles_by_category(self, category): conn = sqlite3.connect(self.db_path) cursor = conn.cursor() # Use direct string concatenation for the MATCH expression. diff --git a/lollms/server/endpoints/lollms_skills_library.py b/lollms/server/endpoints/lollms_skills_library.py index 6141291..b58b062 100644 --- a/lollms/server/endpoints/lollms_skills_library.py +++ b/lollms/server/endpoints/lollms_skills_library.py @@ -25,7 +25,7 @@ from pathlib import Path router = APIRouter() lollmsElfServer:LOLLMSWebUI = LOLLMSWebUI.get_instance() -class DiscussionInfos(BaseModel): +class clientInfos(BaseModel): client_id: str class SkillInfos(BaseModel): @@ -45,18 +45,23 @@ class CategoryData(BaseModel): @router.post("/get_skills_library") -def get_skills_library_categories(discussionInfos:DiscussionInfos): +def get_skills_library_categories(discussionInfos:clientInfos): return {"status":True, "entries":lollmsElfServer.skills_library.dump()} @router.post("/get_skills_library_categories") -def get_skills_library_categories(discussionInfos:DiscussionInfos): +def get_skills_library_categories(discussionInfos:clientInfos): # get_categories returns a list of strings, each entry is a category return {"status":True, "categories":lollmsElfServer.skills_library.get_categories()} -@router.post("/get_skills_library_titles") -def get_skills_library_categories(categoryData:CategoryData): +@router.post("/get_skills_library_titles_by_category") +def get_skills_library_titles(categoryData:CategoryData): # Get titles returns a list of dict each entry has id and title - return {"status":True, "titles":lollmsElfServer.skills_library.get_titles(categoryData.category)} + return {"status":True, "titles":lollmsElfServer.skills_library.get_titles_by_category(categoryData.category)} + +@router.post("/get_skills_library_titles") +def get_skills_library_titles(clientInfos:clientInfos): + # Get titles returns a list of dict each entry has id and title + return {"status":True, "titles":lollmsElfServer.skills_library.get_titles()} @router.post("/get_skills_library_content") def get_skills_library_content(skillInfos:SkillInfos):