mirror of
https://github.com/ParisNeo/lollms.git
synced 2025-01-21 03:55:01 +00:00
added the possibility to ignore rag
This commit is contained in:
parent
7da874228b
commit
e41e9ccc9b
@ -917,7 +917,7 @@ class LollmsApplication(LoLLMsCom):
|
|||||||
trace_exception(ex)
|
trace_exception(ex)
|
||||||
self.warning("Couldn't add documentation to the context. Please verify the vector database")
|
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:
|
if discussion is None:
|
||||||
discussion = self.recover_discussion(client_id)
|
discussion = self.recover_discussion(client_id)
|
||||||
|
|
||||||
|
@ -30,9 +30,10 @@ def read_text(text: str, tts_module:LollmsTTS, llm:APScript) -> str:
|
|||||||
llm.new_message("")
|
llm.new_message("")
|
||||||
|
|
||||||
# Return the path to the generated audio file
|
# Return the path to the generated audio file
|
||||||
return str(audio_file_path)
|
return "Reading text:\n"+text
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return trace_exception(e)
|
trace_exception(e)
|
||||||
|
return str(e)
|
||||||
|
|
||||||
|
|
||||||
# Metadata function
|
# Metadata function
|
||||||
|
50
lollms/functions/writing/create_text_file.py
Normal file
50
lollms/functions/writing/create_text_file.py
Normal file
@ -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
|
||||||
|
}
|
@ -107,6 +107,7 @@ class AIPersonality:
|
|||||||
app:LoLLMsCom=None,
|
app:LoLLMsCom=None,
|
||||||
run_scripts=True,
|
run_scripts=True,
|
||||||
selected_language=None,
|
selected_language=None,
|
||||||
|
ignore_discussion_documents_rag=False,
|
||||||
is_relative_path=True,
|
is_relative_path=True,
|
||||||
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY,
|
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY,
|
||||||
callback: Callable[[str, MSG_TYPE, dict, list], bool]=None
|
callback: Callable[[str, MSG_TYPE, dict, list], bool]=None
|
||||||
@ -158,6 +159,7 @@ class AIPersonality:
|
|||||||
self._language: str = "english"
|
self._language: str = "english"
|
||||||
self._supported_languages: str = []
|
self._supported_languages: str = []
|
||||||
self._selected_language: str = selected_language
|
self._selected_language: str = selected_language
|
||||||
|
self._ignore_discussion_documents_rag:bool = ignore_discussion_documents_rag
|
||||||
|
|
||||||
self._languages: List[dict]=[]
|
self._languages: List[dict]=[]
|
||||||
|
|
||||||
@ -828,6 +830,8 @@ class AIPersonality:
|
|||||||
self._category_desc = config.get("category", self._category)
|
self._category_desc = config.get("category", self._category)
|
||||||
self._language = config.get("language", self._language)
|
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_description = config.get("personality_description", self._personality_description)
|
||||||
self._personality_conditioning = config.get("personality_conditioning", self._personality_conditioning)
|
self._personality_conditioning = config.get("personality_conditioning", self._personality_conditioning)
|
||||||
@ -1112,6 +1116,7 @@ class AIPersonality:
|
|||||||
"language": self._language,
|
"language": self._language,
|
||||||
"supported_languages": self._supported_languages,
|
"supported_languages": self._supported_languages,
|
||||||
"selected_language": self._selected_language,
|
"selected_language": self._selected_language,
|
||||||
|
"ignore_discussion_documents_rag": self._ignore_discussion_documents_rag,
|
||||||
"personality_description": self._personality_description,
|
"personality_description": self._personality_description,
|
||||||
"personality_conditioning": self._personality_conditioning,
|
"personality_conditioning": self._personality_conditioning,
|
||||||
"welcome_message": self._welcome_message,
|
"welcome_message": self._welcome_message,
|
||||||
@ -1152,6 +1157,7 @@ class AIPersonality:
|
|||||||
"language": self._language,
|
"language": self._language,
|
||||||
"supported_languages": self._supported_languages,
|
"supported_languages": self._supported_languages,
|
||||||
"selected_language": self._selected_language,
|
"selected_language": self._selected_language,
|
||||||
|
"ignore_discussion_documents_rag": self._ignore_discussion_documents_rag,
|
||||||
"personality_description": self._personality_description,
|
"personality_description": self._personality_description,
|
||||||
"personality_conditioning": self._personality_conditioning,
|
"personality_conditioning": self._personality_conditioning,
|
||||||
"welcome_message": self._welcome_message,
|
"welcome_message": self._welcome_message,
|
||||||
@ -1285,6 +1291,17 @@ class AIPersonality:
|
|||||||
"""Set the selected_language."""
|
"""Set the selected_language."""
|
||||||
self._selected_language = value
|
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
|
@property
|
||||||
def personality_description(self) -> str:
|
def personality_description(self) -> str:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user