diff --git a/lollms/app.py b/lollms/app.py index 23206f9..2268190 100644 --- a/lollms/app.py +++ b/lollms/app.py @@ -917,7 +917,7 @@ class LollmsApplication(LoLLMsCom): trace_exception(ex) self.warning("Couldn't add documentation to the context. Please verify the vector database") - if (len(client.discussion.text_files) > 0) and client.discussion.vectorizer is not None: + if not self.personality.ignore_discussion_documents_rag and (len(client.discussion.text_files) > 0) and client.discussion.vectorizer is not None: if discussion is None: discussion = self.recover_discussion(client_id) diff --git a/lollms/functions/tts/read_text.py b/lollms/functions/tts/read_text.py index 37abe39..b9dea53 100644 --- a/lollms/functions/tts/read_text.py +++ b/lollms/functions/tts/read_text.py @@ -30,9 +30,10 @@ def read_text(text: str, tts_module:LollmsTTS, llm:APScript) -> str: llm.new_message("") # Return the path to the generated audio file - return str(audio_file_path) + return "Reading text:\n"+text except Exception as e: - return trace_exception(e) + trace_exception(e) + return str(e) # Metadata function diff --git a/lollms/functions/writing/create_text_file.py b/lollms/functions/writing/create_text_file.py new file mode 100644 index 0000000..047c438 --- /dev/null +++ b/lollms/functions/writing/create_text_file.py @@ -0,0 +1,50 @@ +# Lollms function call definition file +# File Name: create_file.py +# Author: ParisNeo +# Description: This function creates a text file with specified content in the 'text_data' subfolder. + +# Import necessary modules +from functools import partial +from typing import Union +from pathlib import Path +from lollms.utilities import PackageManager +from lollms.client_session import Client +from ascii_colors import trace_exception + +# Core function to create a file +def create_file(file_name: str, content: str, client:Client) -> Union[str, None]: + """ + Creates a text file with the specified content in the 'text_data' subfolder. + + Parameters: + file_name (str): The name of the file to be created. + content (str): The content to be written into the file. + + Returns: + Union[str, None]: Returns None if successful, otherwise returns the exception message. + """ + try: + # Define the path to the 'text_data' subfolder + + # Define the full file path + file_path = client.discussion_path/ 'text_data' / file_name + + # Write the content to the file + file_path.write_text(content, encoding='utf-8') + + # Return None if successful + return None + except Exception as e: + return trace_exception(e) + +# Metadata function +def create_file_function(client:Client): + return { + "function_name": "create_file", # The function name in string + "function": partial(create_file, client=client), # The function to be called + "function_description": "Creates a text file with specified content in the 'text_data' subfolder.", # Description of the function + "function_parameters": [ + {"name": "file_name", "type": "str"}, + {"name": "content", "type": "str"} + ] # The set of parameters + } diff --git a/lollms/personality.py b/lollms/personality.py index 71e4302..fc300e8 100644 --- a/lollms/personality.py +++ b/lollms/personality.py @@ -107,6 +107,7 @@ class AIPersonality: app:LoLLMsCom=None, run_scripts=True, selected_language=None, + ignore_discussion_documents_rag=False, is_relative_path=True, installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY, callback: Callable[[str, MSG_TYPE, dict, list], bool]=None @@ -158,6 +159,7 @@ class AIPersonality: self._language: str = "english" self._supported_languages: str = [] self._selected_language: str = selected_language + self._ignore_discussion_documents_rag:bool = ignore_discussion_documents_rag self._languages: List[dict]=[] @@ -828,6 +830,8 @@ class AIPersonality: self._category_desc = config.get("category", self._category) self._language = config.get("language", self._language) + self._ignore_discussion_documents_rag = config.get("ignore_discussion_documents_rag", self._ignore_discussion_documents_rag) + self._personality_description = config.get("personality_description", self._personality_description) self._personality_conditioning = config.get("personality_conditioning", self._personality_conditioning) @@ -1112,6 +1116,7 @@ class AIPersonality: "language": self._language, "supported_languages": self._supported_languages, "selected_language": self._selected_language, + "ignore_discussion_documents_rag": self._ignore_discussion_documents_rag, "personality_description": self._personality_description, "personality_conditioning": self._personality_conditioning, "welcome_message": self._welcome_message, @@ -1152,6 +1157,7 @@ class AIPersonality: "language": self._language, "supported_languages": self._supported_languages, "selected_language": self._selected_language, + "ignore_discussion_documents_rag": self._ignore_discussion_documents_rag, "personality_description": self._personality_description, "personality_conditioning": self._personality_conditioning, "welcome_message": self._welcome_message, @@ -1285,6 +1291,17 @@ class AIPersonality: """Set the selected_language.""" self._selected_language = value + @property + def ignore_discussion_documents_rag(self) -> str: + """Get the ignore_discussion_documents_rag.""" + return self._ignore_discussion_documents_rag + + @ignore_discussion_documents_rag.setter + def ignore_discussion_documents_rag(self, value: str): + """Set the ignore_discussion_documents_rag.""" + self._ignore_discussion_documents_rag = value + + @property def personality_description(self) -> str: """