From e8ffec9cd022260ea7debe57a85b233ed255f773 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sat, 21 Dec 2024 00:51:57 +0100 Subject: [PATCH] added lightrag --- lollms/app.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lollms/app.py b/lollms/app.py index b4311b8..fbfa293 100644 --- a/lollms/app.py +++ b/lollms/app.py @@ -1190,7 +1190,35 @@ class LollmsApplication(LoLLMsCom): "similarity":1-chunk.distance, }) documentation += document_infos - + + if (len(self.config.remote_databases) > 0) and not not self.config.rag_deactivate: + for db in self.config.remote_databases: + parts = db.split("::") + if len(parts>=4): + if parts[1]=="lightrag": + from lollmsvectordb.database_clients.lightrag_client import LollmsLightRagConnector + lc = LollmsLightRagConnector(parts[2]) + if discussion is None: + discussion = self.recover_discussion(client_id) + + if documentation=="": + documentation=f"{self.separator_template}".join([ + f"{self.separator_template}{self.start_header_id_template}important information{self.end_header_id_template}Utilize Documentation Data: Always refer to the provided documentation to answer user questions accurately.", + "Absence of Information: If the required information is not available in the documentation, inform the user that the requested information is not present in the documentation section.", + "Strict Adherence to Documentation: It is strictly prohibited to provide answers without concrete evidence from the documentation.", + "Cite Your Sources: After providing an answer, include the full path to the document where the information was found.", + f"{self.start_header_id_template}Documentation{self.end_header_id_template}"]) + documentation += f"{self.separator_template}" + if query is None: + if self.config.rag_build_keys_words: + self.personality.step_start("Building vector store query") + query = self.personality.fast_gen(f"{self.separator_template}{self.start_header_id_template}instruction: Read the discussion and rewrite the last prompt for someone who didn't read the entire discussion.\nDo not answer the prompt. Do not add explanations.{self.separator_template}{self.start_header_id_template}discussion:\n{discussion[-2048:]}{self.separator_template}{self.start_header_id_template}enhanced query: ", max_generation_size=256, show_progress=True, callback=self.personality.sink) + self.personality.step_end("Building vector store query") + ASCIIColors.cyan(f"Query: {query}") + else: + query = current_message.content + documentation += lc.query(query) + if (len(client.discussion.text_files) > 0) and client.discussion.vectorizer is not None: if not self.config.rag_deactivate: if discussion is None: