Update app.py

This commit is contained in:
Saifeddine ALOUI 2024-12-03 09:06:14 +01:00 committed by GitHub
parent 604dfb2533
commit 58ab336aa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -907,6 +907,7 @@ class LollmsApplication(LoLLMsCom):
Returns: Returns:
Tuple[str, str, List[str]]: The prepared query, original message content, and tokenized query. Tuple[str, str, List[str]]: The prepared query, original message content, and tokenized query.
""" """
skills_detials=[]
skills = [] skills = []
documentation_entries = [] documentation_entries = []
start_ai_header_id_template = self.config.start_ai_header_id_template start_ai_header_id_template = self.config.start_ai_header_id_template
@ -1272,12 +1273,13 @@ The reformulation must be placed inside a json markdown tag like this:
if self.config.debug: if self.config.debug:
ASCIIColors.info(f"Query : {query}") ASCIIColors.info(f"Query : {query}")
skill_titles, skills, similarities = self.skills_library.query_vector_db(query, top_k=3, min_similarity=self.config.rag_min_correspondance)#query_entry_fts(query) skill_titles, skills, similarities = self.skills_library.query_vector_db(query, top_k=3, min_similarity=self.config.rag_min_correspondance)#query_entry_fts(query)
knowledge_infos={"titles":skill_titles,"contents":skills, "similarities":similarities} skills_detials=[{"title": title, "content":content, "similarity":similarity} for title, content, similarity in zip(skill_titles, skills, similarities)]
if len(skills)>0: if len(skills)>0:
if knowledge=="": if knowledge=="":
knowledge=f"{self.system_custom_header(knowledge)}\n" knowledge=f"{self.system_custom_header(knowledge)}\n"
for i,(title, content) in enumerate(zip(skill_titles,skills)): for i,skill in enumerate(skills_detials):
knowledge += self.system_custom_header(f"knowledge {i}") +f"\ntitle:\n{title}\ncontent:\n{content}\n" knowledge += self.system_custom_header(f"knowledge {i}") +f"\ntitle:\n{skill['title']}\ncontent:\n{skill['content']}\n"
self.personality.step_end("Adding skills") self.personality.step_end("Adding skills")
self.personality.step_end("Querying skills library") self.personality.step_end("Querying skills library")
except Exception as ex: except Exception as ex:
@ -1467,7 +1469,7 @@ The reformulation must be placed inside a json markdown tag like this:
"ai_prefix":ai_prefix, "ai_prefix":ai_prefix,
"extra":"", "extra":"",
"available_space":available_space, "available_space":available_space,
"skills":[{"title": title, "content":content, "similarity":similarity} for title, content, similarity in zip(skill_titles, skills, similarities)], "skills":skills_detials,
"is_continue":is_continue, "is_continue":is_continue,
"previous_chunk":previous_chunk, "previous_chunk":previous_chunk,
"prompt":current_message.content "prompt":current_message.content