mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-04-15 14:36:34 +00:00
fixed install model bug
This commit is contained in:
parent
44aea43d18
commit
fb03900ef6
@ -631,11 +631,14 @@ class LollmsApplication(LoLLMsCom):
|
||||
# Check if there is discussion knowledge to add to the prompt
|
||||
if self.config.activate_skills_lib:
|
||||
try:
|
||||
self.personality.step_start("Building skills library")
|
||||
self.personality.step_start("Querying skills library")
|
||||
if discussion is None:
|
||||
discussion = self.recover_discussion(client_id)
|
||||
self.personality.step_start("Building query")
|
||||
query = self.personality.fast_gen(f"!@>system: Read the discussion and reformulate {self.config.user_name}'s request.\nDo not answer the request.\nDo not add explanations.\n!@>discussion:\n{discussion[-2048:]}\n!@>search query: ", max_generation_size=256, show_progress=True, callback=self.personality.sink)
|
||||
self.personality.step_end("Building query")
|
||||
# skills = self.skills_library.query_entry(query)
|
||||
self.personality.step_start("Adding skills")
|
||||
if self.config.debug:
|
||||
ASCIIColors.info(f"Query : {query}")
|
||||
skill_titles, skills = self.skills_library.query_vector_db(query, top_k=3, max_dist=1000)#query_entry_fts(query)
|
||||
@ -645,11 +648,13 @@ class LollmsApplication(LoLLMsCom):
|
||||
knowledge=f"!@>knowledge:\n"
|
||||
for i,(title, content) in enumerate(zip(skill_titles,skills)):
|
||||
knowledge += f"!@>knowledge {i}:\n!@>title:\n{title}\ncontent:\n{content}"
|
||||
self.personality.step_end("Building skills library")
|
||||
self.personality.step_end("Adding skills")
|
||||
self.personality.step_end("Querying skills library")
|
||||
except Exception as ex:
|
||||
ASCIIColors.error(ex)
|
||||
self.warning("Couldn't add long term memory information to the context. Please verify the vector database") # Add information about the user
|
||||
self.personality.step_end("Building skills library",False)
|
||||
self.personality.step_end("Adding skills")
|
||||
self.personality.step_end("Querying skills library",False)
|
||||
user_description=""
|
||||
if self.config.use_user_informations_in_discussion:
|
||||
user_description="!@>User description:\n"+self.config.user_description+"\n"
|
||||
|
@ -174,19 +174,57 @@ class SkillsLibrary:
|
||||
res = cursor.fetchall()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return [r[0] for r in res]
|
||||
return list(set([r[0] for r in res]))
|
||||
|
||||
|
||||
def get_titles(self, category):
|
||||
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 title FROM skills_library WHERE category=?"
|
||||
query = "SELECT id, title FROM skills_library WHERE category=?"
|
||||
cursor.execute(query,(category,))
|
||||
res = cursor.fetchall()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return [{"id":r[0], "title":r[1]} for r in res]
|
||||
|
||||
def get_content(self, id):
|
||||
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 content FROM skills_library WHERE id = ?"
|
||||
cursor.execute(query, (id,))
|
||||
res = cursor.fetchall()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return [r[0] for r in res]
|
||||
|
||||
def get_skill(self, id):
|
||||
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, category, title, content FROM skills_library WHERE id = ?"
|
||||
cursor.execute(query, (id,))
|
||||
res = cursor.fetchall()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return [{"id":r[0], "category":r[1], "title":r[2], "content":r[3]} for r in res]
|
||||
|
||||
def update_skill(self, id, category, title, content):
|
||||
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 = "UPDATE skills_library SET category=?, title=?, content=? WHERE id = ?"
|
||||
cursor.execute(query, (category,title,content))
|
||||
res = cursor.fetchall()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return [{"id":r[0], "category":r[1], "title":r[2], "content":r[3]} for r in res]
|
||||
|
||||
|
||||
def remove_entry(self, id):
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
|
@ -28,14 +28,20 @@ lollmsElfServer:LOLLMSWebUI = LOLLMSWebUI.get_instance()
|
||||
class DiscussionInfos(BaseModel):
|
||||
client_id: str
|
||||
|
||||
class CategoryData(BaseModel):
|
||||
class SkillInfos(BaseModel):
|
||||
client_id: str
|
||||
skill_id: int
|
||||
|
||||
class SkillUpdateInfos(BaseModel):
|
||||
client_id: str
|
||||
skill_id: int
|
||||
category: str
|
||||
title: str
|
||||
content: str
|
||||
|
||||
class CategoryData(BaseModel):
|
||||
client_id: str
|
||||
category: str
|
||||
title: str
|
||||
|
||||
|
||||
@router.post("/get_skills_library")
|
||||
@ -44,16 +50,23 @@ def get_skills_library_categories(discussionInfos:DiscussionInfos):
|
||||
|
||||
@router.post("/get_skills_library_categories")
|
||||
def get_skills_library_categories(discussionInfos:DiscussionInfos):
|
||||
# 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):
|
||||
# Get titles returns a list of dict each entry has id and title
|
||||
return {"status":True, "titles":lollmsElfServer.skills_library.get_titles(categoryData.category)}
|
||||
|
||||
@router.post("/get_skills_library_content")
|
||||
def get_skills_library_categories(categoryData:CategoryData):
|
||||
return {"status":True, "contents":lollmsElfServer.skills_library.get_titles(categoryData.category)}
|
||||
def get_skills_library_content(skillInfos:SkillInfos):
|
||||
# Get the content of the skill from the id, the output is a list of dicts each entry has id, category, title and content
|
||||
return {"status":True, "contents":lollmsElfServer.skills_library.get_skill(skillInfos.skill_id)}
|
||||
|
||||
@router.post("/edit_skill")
|
||||
def edit_skill(skillInfos:SkillUpdateInfos):
|
||||
lollmsElfServer.skills_library.update_skill(skillInfos.skill_id, skillInfos.category, skillInfos.title, skillInfos.content)
|
||||
return {"status":True}
|
||||
|
||||
@router.post("/add_discussion_to_skills_library")
|
||||
def add_discussion_to_skills_library(discussionInfos:DiscussionInfos):
|
||||
|
@ -36,7 +36,6 @@ def add_events(sio:socketio):
|
||||
def install_model(sid, data):
|
||||
client_id = sid
|
||||
sanitize_path(data["type"])
|
||||
sanitize_path(data["path"])
|
||||
sanitize_path(data["variant_name"])
|
||||
tpe = threading.Thread(target=lollmsElfServer.binding.install_model, args=(data["type"], data["path"], data["variant_name"], client_id))
|
||||
tpe.start()
|
||||
|
Loading…
x
Reference in New Issue
Block a user