mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-18 20:27:58 +00:00
removed lollms personalities
This commit is contained in:
parent
72a2466d3e
commit
424e1fd9ac
2
LICENSE
2
LICENSE
@ -186,7 +186,7 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
Copyright Copyright 2023 Saifeddine ALOUI (aka: ParisNeo)
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -45,9 +45,6 @@ Events generated:
|
|||||||
- Actions:
|
- Actions:
|
||||||
- Retrieves the path to the personalities folder from the server (`self.personalities_path`).
|
- Retrieves the path to the personalities folder from the server (`self.personalities_path`).
|
||||||
- Initializes an empty dictionary to store the available personalities.
|
- Initializes an empty dictionary to store the available personalities.
|
||||||
- Iterates over each language folder in the personalities folder.
|
|
||||||
- Checks if the current item is a directory.
|
|
||||||
- Initializes an empty dictionary to store the personalities within the language.
|
|
||||||
- Iterates over each category folder within the language folder.
|
- Iterates over each category folder within the language folder.
|
||||||
- Checks if the current item is a directory.
|
- Checks if the current item is a directory.
|
||||||
- Initializes an empty list to store the personalities within the category.
|
- Initializes an empty list to store the personalities within the category.
|
||||||
@ -60,7 +57,6 @@ Events generated:
|
|||||||
- Sets the `avatar` field of the personality info based on the available logo file.
|
- Sets the `avatar` field of the personality info based on the available logo file.
|
||||||
- Appends the personality info to the list of personalities within the category.
|
- Appends the personality info to the list of personalities within the category.
|
||||||
- Adds the list of personalities to the dictionary of the current category within the language.
|
- Adds the list of personalities to the dictionary of the current category within the language.
|
||||||
- Adds the dictionary of categories to the dictionary of the current language.
|
|
||||||
- Sends a response to the client containing the dictionary of available personalities.
|
- Sends a response to the client containing the dictionary of available personalities.
|
||||||
|
|
||||||
Events generated:
|
Events generated:
|
||||||
@ -84,32 +80,14 @@ Events generated:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### `list_available_personalities_languages`
|
|
||||||
- Event: `'list_available_personalities_languages'`
|
|
||||||
- Description: This event is triggered when a client requests a list of available personality languages.
|
|
||||||
- Actions:
|
|
||||||
- Attempts to retrieve a list of available personality languages by iterating over the `self.personalities_path` directory.
|
|
||||||
- Sends a response to the client containing the success status and the list of available personality languages.
|
|
||||||
|
|
||||||
Parameters: None
|
|
||||||
|
|
||||||
Events:
|
|
||||||
- `'available_personalities_languages_list'`: This event is emitted as a response to the client after listing the available personality languages.
|
|
||||||
- Data:
|
|
||||||
- `'success'` (boolean): Indicates whether the operation was successful or not.
|
|
||||||
- `'available_personalities_languages'` (list): Contains the available personality languages as a list of strings.
|
|
||||||
|
|
||||||
|
|
||||||
#### `list_available_personalities_categories`
|
#### `list_available_personalities_categories`
|
||||||
- Event: `'list_available_personalities_categories'`
|
- Event: `'list_available_personalities_categories'`
|
||||||
- Description: This event is triggered when a client requests a list of available personality categories based on a specified language.
|
- Description: This event is triggered when a client requests a list of available personality categories based on a specified language.
|
||||||
- Parameters:
|
- Parameters:
|
||||||
- `data`: A dictionary containing the following parameter:
|
- `data`: An empty dictionary:
|
||||||
- `language`: The language for which to retrieve available personality categories.
|
|
||||||
|
|
||||||
- Actions:
|
- Actions:
|
||||||
- Extracts the `language` parameter from the request data.
|
- Attempts to retrieve the available personality categories.
|
||||||
- Attempts to retrieve the available personality categories for the specified language.
|
|
||||||
- Emits an event `'available_personalities_categories_list'` to the client.
|
- Emits an event `'available_personalities_categories_list'` to the client.
|
||||||
- If successful, sends a response with a list of available personality categories in the `'available_personalities_categories'` field of the event data.
|
- If successful, sends a response with a list of available personality categories in the `'available_personalities_categories'` field of the event data.
|
||||||
- If an error occurs, sends a response with an error message in the `'error'` field of the event data.
|
- If an error occurs, sends a response with an error message in the `'error'` field of the event data.
|
||||||
|
@ -150,8 +150,13 @@ class LollmsApplication:
|
|||||||
for i in to_remove:
|
for i in to_remove:
|
||||||
self.unmount_personality(i)
|
self.unmount_personality(i)
|
||||||
|
|
||||||
|
if self.config.active_personality_id>=0 and self.config.active_personality_id<len(self.mounted_personalities):
|
||||||
|
self.personality = self.mounted_personalities[self.config.active_personality_id]
|
||||||
|
else:
|
||||||
|
self.config["personalities"].insert(0, "generic/lollms")
|
||||||
|
self.mount_personality(0, callback = None)
|
||||||
|
self.config.active_personality_id = 0
|
||||||
self.personality = self.mounted_personalities[self.config.active_personality_id]
|
self.personality = self.mounted_personalities[self.config.active_personality_id]
|
||||||
|
|
||||||
def set_personalities_callbacks(self, callback: Callable[[str, int, dict], bool]=None):
|
def set_personalities_callbacks(self, callback: Callable[[str, int, dict], bool]=None):
|
||||||
for personality in self.mount_personalities:
|
for personality in self.mount_personalities:
|
||||||
personality.setCallback(callback)
|
personality.setCallback(callback)
|
||||||
|
@ -236,19 +236,11 @@ class LoLLMsServer(LollmsApplication):
|
|||||||
print(f"Problem with model : {model}")
|
print(f"Problem with model : {model}")
|
||||||
emit('available_models_list', {'success':True, 'available_models': models}, room=request.sid)
|
emit('available_models_list', {'success':True, 'available_models': models}, room=request.sid)
|
||||||
|
|
||||||
@self.socketio.on('list_available_personalities_languages')
|
|
||||||
def handle_list_available_personalities_languages():
|
|
||||||
try:
|
|
||||||
languages = [l for l in self.personalities_path.iterdir()]
|
|
||||||
emit('available_personalities_languages_list', {'success': True, 'available_personalities_languages': languages})
|
|
||||||
except Exception as ex:
|
|
||||||
emit('available_personalities_languages_list', {'success': False, 'error':str(ex)})
|
|
||||||
|
|
||||||
@self.socketio.on('list_available_personalities_categories')
|
@self.socketio.on('list_available_personalities_categories')
|
||||||
def handle_list_available_personalities_categories(data):
|
def handle_list_available_personalities_categories(data):
|
||||||
try:
|
try:
|
||||||
language = data["language"]
|
categories = [l for l in (self.personalities_path).iterdir()]
|
||||||
categories = [l for l in (self.personalities_path/language).iterdir()]
|
|
||||||
emit('available_personalities_categories_list', {'success': True, 'available_personalities_categories': categories})
|
emit('available_personalities_categories_list', {'success': True, 'available_personalities_categories': categories})
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
emit('available_personalities_categories_list', {'success': False, 'error':str(ex)})
|
emit('available_personalities_categories_list', {'success': False, 'error':str(ex)})
|
||||||
@ -256,9 +248,8 @@ class LoLLMsServer(LollmsApplication):
|
|||||||
@self.socketio.on('list_available_personalities_names')
|
@self.socketio.on('list_available_personalities_names')
|
||||||
def handle_list_available_personalities_names(data):
|
def handle_list_available_personalities_names(data):
|
||||||
try:
|
try:
|
||||||
language = data["language"]
|
|
||||||
category = data["category"]
|
category = data["category"]
|
||||||
personalities = [l for l in (self.personalities_path/language/category).iterdir()]
|
personalities = [l for l in (self.personalities_path/category).iterdir()]
|
||||||
emit('list_available_personalities_names_list', {'success': True, 'list_available_personalities_names': personalities})
|
emit('list_available_personalities_names_list', {'success': True, 'list_available_personalities_names': personalities})
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
emit('list_available_personalities_names_list', {'success': False, 'error':str(ex)})
|
emit('list_available_personalities_names_list', {'success': False, 'error':str(ex)})
|
||||||
@ -625,7 +616,7 @@ class LoLLMsServer(LollmsApplication):
|
|||||||
print(f"{ASCIIColors.color_red}Mounted personalities : {ASCIIColors.color_reset}{self.config.personalities}")
|
print(f"{ASCIIColors.color_red}Mounted personalities : {ASCIIColors.color_reset}{self.config.personalities}")
|
||||||
if len(self.config.personalities)==0:
|
if len(self.config.personalities)==0:
|
||||||
ASCIIColors.warning("No personality selected. Selecting lollms. You can mount other personalities using lollms-settings application")
|
ASCIIColors.warning("No personality selected. Selecting lollms. You can mount other personalities using lollms-settings application")
|
||||||
self.config.personalities = ["english/generic/lollms"]
|
self.config.personalities = ["generic/lollms"]
|
||||||
self.config.save_config()
|
self.config.save_config()
|
||||||
|
|
||||||
if self.config.active_personality_id>=len(self.config.personalities):
|
if self.config.active_personality_id>=len(self.config.personalities):
|
||||||
|
@ -51,7 +51,8 @@ class LLMBinding:
|
|||||||
self.file_extension = file_extension
|
self.file_extension = file_extension
|
||||||
self.seed = config["seed"]
|
self.seed = config["seed"]
|
||||||
|
|
||||||
self.configuration_file_path = lollms_paths.personal_configuration_path/f"binding_{self.binding_folder_name}.yaml"
|
self.configuration_file_path = lollms_paths.personal_configuration_path/self.binding_folder_name/f"config.yaml"
|
||||||
|
self.configuration_file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
self.binding_config.config.file_path = self.configuration_file_path
|
self.binding_config.config.file_path = self.configuration_file_path
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
@ -24,7 +24,7 @@ repeat_penalty: 1.2
|
|||||||
n_threads: 8
|
n_threads: 8
|
||||||
|
|
||||||
#Personality parameters
|
#Personality parameters
|
||||||
personalities: ["english/generic/lollms"]
|
personalities: ["generic/lollms"]
|
||||||
active_personality_id: 0
|
active_personality_id: 0
|
||||||
override_personality_model_parameters: false #if true the personality parameters are overriden by those of the configuration (may affect personality behaviour)
|
override_personality_model_parameters: false #if true the personality parameters are overriden by those of the configuration (may affect personality behaviour)
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ DEFAULT_CONFIG = {
|
|||||||
"n_threads": 8,
|
"n_threads": 8,
|
||||||
|
|
||||||
#Personality parameters
|
#Personality parameters
|
||||||
"personalities": ["english/generic/lollms"],
|
"personalities": ["generic/lollms"],
|
||||||
"active_personality_id": 0,
|
"active_personality_id": 0,
|
||||||
"override_personality_model_parameters": False, #if true the personality parameters are overriden by those of the configuration (may affect personality behaviour)
|
"override_personality_model_parameters": False, #if true the personality parameters are overriden by those of the configuration (may affect personality behaviour)
|
||||||
|
|
||||||
|
@ -86,7 +86,6 @@ class AIPersonality:
|
|||||||
self._author: str = "ParisNeo"
|
self._author: str = "ParisNeo"
|
||||||
self._name: str = "lollms"
|
self._name: str = "lollms"
|
||||||
self._user_name: str = "user"
|
self._user_name: str = "user"
|
||||||
self._language: str = "english"
|
|
||||||
self._category: str = "General"
|
self._category: str = "General"
|
||||||
|
|
||||||
# Conditionning
|
# Conditionning
|
||||||
@ -162,7 +161,7 @@ Date: {{date}}
|
|||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.language}/{self.category}/{self.name}"
|
return f"{self.category}/{self.name}"
|
||||||
|
|
||||||
|
|
||||||
def load_personality(self, package_path=None):
|
def load_personality(self, package_path=None):
|
||||||
@ -201,7 +200,6 @@ Date: {{date}}
|
|||||||
self._author = config.get("author", self._author)
|
self._author = config.get("author", self._author)
|
||||||
self._name = config.get("name", self._name)
|
self._name = config.get("name", self._name)
|
||||||
self._user_name = config.get("user_name", self._user_name)
|
self._user_name = config.get("user_name", self._user_name)
|
||||||
self._language = config.get("language", self._language)
|
|
||||||
self._category = config.get("category", self._category)
|
self._category = config.get("category", self._category)
|
||||||
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)
|
||||||
@ -294,7 +292,6 @@ Date: {{date}}
|
|||||||
"version": self._version,
|
"version": self._version,
|
||||||
"name": self._name,
|
"name": self._name,
|
||||||
"user_name": self._user_name,
|
"user_name": self._user_name,
|
||||||
"language": self._language,
|
|
||||||
"category": self._category,
|
"category": self._category,
|
||||||
"personality_description": self._personality_description,
|
"personality_description": self._personality_description,
|
||||||
"personality_conditioning": self._personality_conditioning,
|
"personality_conditioning": self._personality_conditioning,
|
||||||
@ -334,7 +331,6 @@ Date: {{date}}
|
|||||||
"version": self._version,
|
"version": self._version,
|
||||||
"name": self._name,
|
"name": self._name,
|
||||||
"user_name": self._user_name,
|
"user_name": self._user_name,
|
||||||
"language": self._language,
|
|
||||||
"category": self._category,
|
"category": self._category,
|
||||||
"personality_description": self._personality_description,
|
"personality_description": self._personality_description,
|
||||||
"personality_conditioning": self._personality_conditioning,
|
"personality_conditioning": self._personality_conditioning,
|
||||||
@ -418,16 +414,6 @@ Date: {{date}}
|
|||||||
"""Set the user name."""
|
"""Set the user name."""
|
||||||
self._user_name = value
|
self._user_name = value
|
||||||
|
|
||||||
@property
|
|
||||||
def language(self) -> str:
|
|
||||||
"""Get the language."""
|
|
||||||
return self._language
|
|
||||||
|
|
||||||
@language.setter
|
|
||||||
def language(self, value: str):
|
|
||||||
"""Set the language."""
|
|
||||||
self._language = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def category(self) -> str:
|
def category(self) -> str:
|
||||||
"""Get the category."""
|
"""Get the category."""
|
||||||
@ -939,7 +925,9 @@ class APScript(StateMachine):
|
|||||||
self.personality = personality
|
self.personality = personality
|
||||||
self.personality_config = personality_config
|
self.personality_config = personality_config
|
||||||
self.installation_option = personality.installation_option
|
self.installation_option = personality.installation_option
|
||||||
self.configuration_file_path = self.personality.lollms_paths.personal_configuration_path/f"personality_{self.personality.personality_folder_name}.yaml"
|
self.configuration_file_path = self.personality.lollms_paths.personal_configuration_path/self.personality.personality_folder_name/f"config.yaml"
|
||||||
|
self.configuration_file_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
self.personality_config.config.file_path = self.configuration_file_path
|
self.personality_config.config.file_path = self.configuration_file_path
|
||||||
|
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
@ -1146,7 +1134,7 @@ class APScript(StateMachine):
|
|||||||
if callback:
|
if callback:
|
||||||
callback(step_text, MSG_TYPE.MSG_TYPE_STEP_START)
|
callback(step_text, MSG_TYPE.MSG_TYPE_STEP_START)
|
||||||
|
|
||||||
def step_end(self, step_text, status=True, callback: Callable[[str, int, dict], bool]=None):
|
def step_end(self, step_text, status=True, callback: Callable[[str, int, dict, list], bool]=None):
|
||||||
"""This triggers a step end
|
"""This triggers a step end
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -1211,7 +1199,7 @@ class APScript(StateMachine):
|
|||||||
if callback:
|
if callback:
|
||||||
callback(info, MSG_TYPE.MSG_TYPE_INFO)
|
callback(info, MSG_TYPE.MSG_TYPE_INFO)
|
||||||
|
|
||||||
def json(self, json_infos:dict, callback: Callable[[str, int, dict], bool]=None, indent=4):
|
def json(self, title:str, json_infos:dict, callback: Callable[[str, int, dict, list], bool]=None, indent=4):
|
||||||
"""This sends json data to front end
|
"""This sends json data to front end
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -1222,7 +1210,7 @@ class APScript(StateMachine):
|
|||||||
callback = self.callback
|
callback = self.callback
|
||||||
|
|
||||||
if callback:
|
if callback:
|
||||||
callback(json.dumps(json_infos, indent=indent), MSG_TYPE.MSG_TYPE_JSON_INFOS)
|
callback("", MSG_TYPE.MSG_TYPE_JSON_INFOS, metadata = [{"title":title, "content":json.dumps(json_infos, indent=indent)}])
|
||||||
|
|
||||||
def ui(self, html_ui:str, callback: Callable[[str, int, dict], bool]=None):
|
def ui(self, html_ui:str, callback: Callable[[str, int, dict], bool]=None):
|
||||||
"""This sends ui elements to front end
|
"""This sends ui elements to front end
|
||||||
@ -1316,7 +1304,7 @@ class APScript(StateMachine):
|
|||||||
if callback:
|
if callback:
|
||||||
callback(step_text, MSG_TYPE.MSG_TYPE_STEP_PROGRESS, {'progress':progress})
|
callback(step_text, MSG_TYPE.MSG_TYPE_STEP_PROGRESS, {'progress':progress})
|
||||||
|
|
||||||
def new_message(self, message_text:str, message_type:MSG_TYPE, metadata=None, callback: Callable[[str, int, dict], bool]=None):
|
def new_message(self, message_text:str, message_type:MSG_TYPE, metadata=[], callback: Callable[[str, int, dict, list], bool]=None):
|
||||||
"""This sends step rogress to front end
|
"""This sends step rogress to front end
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -1327,7 +1315,7 @@ class APScript(StateMachine):
|
|||||||
callback = self.callback
|
callback = self.callback
|
||||||
|
|
||||||
if callback:
|
if callback:
|
||||||
callback(message_text, MSG_TYPE.MSG_TYPE_NEW_MESSAGE, {'type':message_type.value,'metadata':metadata})
|
callback(message_text, MSG_TYPE.MSG_TYPE_NEW_MESSAGE, parameters={'type':message_type.value,'metadata':metadata})
|
||||||
|
|
||||||
def finished_message(self, message_text:str="", callback: Callable[[str, int, dict], bool]=None):
|
def finished_message(self, message_text:str="", callback: Callable[[str, int, dict], bool]=None):
|
||||||
"""This sends step rogress to front end
|
"""This sends step rogress to front end
|
||||||
@ -1383,7 +1371,7 @@ class PersonalityBuilder:
|
|||||||
else:
|
else:
|
||||||
if id>len(self.config["personalities"]):
|
if id>len(self.config["personalities"]):
|
||||||
id = len(self.config["personalities"])-1
|
id = len(self.config["personalities"])-1
|
||||||
if len(self.config["personalities"][id].split("/"))==3:
|
if len(self.config["personalities"][id].split("/"))==2:
|
||||||
self.personality = AIPersonality(
|
self.personality = AIPersonality(
|
||||||
self.lollms_paths.personalities_zoo_path / self.config["personalities"][id],
|
self.lollms_paths.personalities_zoo_path / self.config["personalities"][id],
|
||||||
self.lollms_paths,
|
self.lollms_paths,
|
||||||
|
@ -298,25 +298,19 @@ class MainMenu(Menu):
|
|||||||
ASCIIColors.green(personality)
|
ASCIIColors.green(personality)
|
||||||
else:
|
else:
|
||||||
ASCIIColors.yellow(personality)
|
ASCIIColors.yellow(personality)
|
||||||
personality_languages = [p.stem for p in self.lollms_app.lollms_paths.personalities_zoo_path.iterdir() if p.is_dir() and not p.name.startswith(".")] + ["Back"]
|
personality_categories = [p.stem for p in (self.lollms_app.lollms_paths.personalities_zoo_path).iterdir() if p.is_dir() and not p.name.startswith(".")]+["Back"]
|
||||||
print("Select language")
|
|
||||||
choice = self.show_menu(personality_languages)
|
|
||||||
if 1 <= choice <= len(personality_languages)-1:
|
|
||||||
language = personality_languages[choice - 1]
|
|
||||||
print(f"You selected language: {ASCIIColors.color_green}{language}{ASCIIColors.color_reset}")
|
|
||||||
personality_categories = [p.stem for p in (self.lollms_app.lollms_paths.personalities_zoo_path/language).iterdir() if p.is_dir() and not p.name.startswith(".")]+["Back"]
|
|
||||||
print("Select category")
|
print("Select category")
|
||||||
choice = self.show_menu(personality_categories)
|
choice = self.show_menu(personality_categories)
|
||||||
if 1 <= choice <= len(personality_categories)-1:
|
if 1 <= choice <= len(personality_categories)-1:
|
||||||
category = personality_categories[choice - 1]
|
category = personality_categories[choice - 1]
|
||||||
print(f"You selected category: {ASCIIColors.color_green}{category}{ASCIIColors.color_reset}")
|
print(f"You selected category: {ASCIIColors.color_green}{category}{ASCIIColors.color_reset}")
|
||||||
personality_names = [p.stem for p in (self.lollms_app.lollms_paths.personalities_zoo_path/language/category).iterdir() if p.is_dir() and not p.name.startswith(".")]+["Back"]
|
personality_names = [p.stem for p in (self.lollms_app.lollms_paths.personalities_zoo_path/category).iterdir() if p.is_dir() and not p.name.startswith(".")]+["Back"]
|
||||||
print("Select personality")
|
print("Select personality")
|
||||||
choice = self.show_menu(personality_names)
|
choice = self.show_menu(personality_names)
|
||||||
if 1 <= choice <= len(personality_names)-1:
|
if 1 <= choice <= len(personality_names)-1:
|
||||||
name = personality_names[choice - 1]
|
name = personality_names[choice - 1]
|
||||||
print(f"You selected personality: {ASCIIColors.color_green}{name}{ASCIIColors.color_reset}")
|
print(f"You selected personality: {ASCIIColors.color_green}{name}{ASCIIColors.color_reset}")
|
||||||
self.lollms_app.config["personalities"].append(f"{language}/{category}/{name}")
|
self.lollms_app.config["personalities"].append(f"{category}/{name}")
|
||||||
self.lollms_app.mount_personality(len(self.lollms_app.config["personalities"])-1, callback = self.callback)
|
self.lollms_app.mount_personality(len(self.lollms_app.config["personalities"])-1, callback = self.callback)
|
||||||
self.lollms_app.config.save_config()
|
self.lollms_app.config.save_config()
|
||||||
print("Personality mounted successfully!")
|
print("Personality mounted successfully!")
|
||||||
@ -328,10 +322,6 @@ class MainMenu(Menu):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print("Invalid choice!")
|
print("Invalid choice!")
|
||||||
elif 1 <= choice <= len(personality_languages):
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
print("Invalid choice!")
|
|
||||||
|
|
||||||
def vew_mounted_personalities(self):
|
def vew_mounted_personalities(self):
|
||||||
ASCIIColors.info("Here is the list of mounted personalities")
|
ASCIIColors.info("Here is the list of mounted personalities")
|
||||||
|
@ -778,20 +778,20 @@ class PromptReshaper:
|
|||||||
placeholders[placeholder]=detokenize(text_tokens)
|
placeholders[placeholder]=detokenize(text_tokens)
|
||||||
return fill_template(self.template, placeholders)
|
return fill_template(self.template, placeholders)
|
||||||
|
|
||||||
if __name__=="__main__":
|
|
||||||
def tokenize(text):
|
|
||||||
return text.split() # Simple tokenization by splitting on spaces
|
|
||||||
|
|
||||||
def detokenize(tokens):
|
|
||||||
return ' '.join(tokens)
|
|
||||||
|
|
||||||
template = "Hello, {{name}}! How are you feeling {{emotion}} really"
|
class LOLLMSLocalizer:
|
||||||
placeholders = {
|
def __init__(self, dictionary):
|
||||||
"name": "Alice",
|
self.dictionary = dictionary
|
||||||
"emotion": "happy and very happy"
|
|
||||||
}
|
def localize(self, input_string):
|
||||||
max_nb_tokens = 10
|
def replace(match):
|
||||||
|
key = match.group(1)
|
||||||
|
return self.dictionary.get(key, match.group(0))
|
||||||
|
|
||||||
|
import re
|
||||||
|
pattern = r'@<([^>]+)>@'
|
||||||
|
localized_string = re.sub(pattern, replace, input_string)
|
||||||
|
return localized_string
|
||||||
|
|
||||||
|
|
||||||
reshaper = PromptReshaper(template)
|
|
||||||
final_text = reshaper.build(placeholders, tokenize, detokenize, max_nb_tokens,["emotion"])
|
|
||||||
print(final_text)
|
|
2
setup.py
2
setup.py
@ -26,7 +26,7 @@ def get_all_files(path):
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="lollms",
|
name="lollms",
|
||||||
version="2.3.4",
|
version="3.0.0",
|
||||||
author="Saifeddine ALOUI",
|
author="Saifeddine ALOUI",
|
||||||
author_email="aloui.saifeddine@gmail.com",
|
author_email="aloui.saifeddine@gmail.com",
|
||||||
description="A python library for AI personality definition",
|
description="A python library for AI personality definition",
|
||||||
|
Loading…
Reference in New Issue
Block a user