mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-19 20:57:58 +00:00
upgraded configurations
This commit is contained in:
parent
6ae2600aa4
commit
70320699b1
@ -1,5 +1,5 @@
|
|||||||
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
||||||
version: 88
|
version: 90
|
||||||
binding_name: null
|
binding_name: null
|
||||||
model_name: null
|
model_name: null
|
||||||
model_variant: null
|
model_variant: null
|
||||||
@ -86,7 +86,7 @@ xtts_base_url: http://localhost:8020
|
|||||||
xtts_use_deepspeed: false
|
xtts_use_deepspeed: false
|
||||||
xtts_use_streaming_mode: true
|
xtts_use_streaming_mode: true
|
||||||
auto_read: false
|
auto_read: false
|
||||||
current_voice: null
|
xtts_current_voice: null
|
||||||
xtts_current_language: en
|
xtts_current_language: en
|
||||||
|
|
||||||
# Image generation service
|
# Image generation service
|
||||||
@ -145,11 +145,9 @@ audio_silenceTimer: 5000
|
|||||||
# Data vectorization
|
# Data vectorization
|
||||||
activate_skills_lib: false # Activate vectorizing previous conversations
|
activate_skills_lib: false # Activate vectorizing previous conversations
|
||||||
skills_lib_database_name: "default" # Default skills database
|
skills_lib_database_name: "default" # Default skills database
|
||||||
summerize_discussion: false # activate discussion summary (better but adds computation time)
|
|
||||||
|
|
||||||
max_summary_size: 512 # in tokens
|
max_summary_size: 512 # in tokens
|
||||||
data_vectorization_visualize_on_vectorization: false
|
data_vectorization_visualize_on_vectorization: false
|
||||||
use_files: true # Activate using files
|
|
||||||
data_vectorization_activate: true # To activate/deactivate data vectorization
|
data_vectorization_activate: true # To activate/deactivate data vectorization
|
||||||
data_vectorization_method: "tfidf_vectorizer" #"model_embedding" or "tfidf_vectorizer"
|
data_vectorization_method: "tfidf_vectorizer" #"model_embedding" or "tfidf_vectorizer"
|
||||||
data_visualization_method: "PCA" #"PCA" or "TSNE"
|
data_visualization_method: "PCA" #"PCA" or "TSNE"
|
||||||
|
@ -81,7 +81,7 @@ copy_to_clipboard_add_all_details: false
|
|||||||
enable_voice_service: false
|
enable_voice_service: false
|
||||||
xtts_base_url: http://localhost:8020
|
xtts_base_url: http://localhost:8020
|
||||||
auto_read: false
|
auto_read: false
|
||||||
current_voice: null
|
xtts_current_voice: null
|
||||||
xtts_current_language: en
|
xtts_current_language: en
|
||||||
|
|
||||||
# Image generation service
|
# Image generation service
|
||||||
|
@ -81,7 +81,7 @@ copy_to_clipboard_add_all_details: false
|
|||||||
enable_voice_service: false
|
enable_voice_service: false
|
||||||
xtts_base_url: http://localhost:8020
|
xtts_base_url: http://localhost:8020
|
||||||
auto_read: false
|
auto_read: false
|
||||||
current_voice: null
|
xtts_current_voice: null
|
||||||
xtts_current_language: en
|
xtts_current_language: en
|
||||||
|
|
||||||
# Image generation service
|
# Image generation service
|
||||||
|
@ -81,7 +81,7 @@ copy_to_clipboard_add_all_details: false
|
|||||||
enable_voice_service: false
|
enable_voice_service: false
|
||||||
xtts_base_url: http://localhost:8020
|
xtts_base_url: http://localhost:8020
|
||||||
auto_read: false
|
auto_read: false
|
||||||
current_voice: null
|
xtts_current_voice: null
|
||||||
xtts_current_language: en
|
xtts_current_language: en
|
||||||
|
|
||||||
# Image generation service
|
# Image generation service
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
||||||
version: 88
|
version: 90
|
||||||
binding_name: null
|
binding_name: null
|
||||||
model_name: null
|
model_name: null
|
||||||
model_variant: null
|
model_variant: null
|
||||||
@ -86,7 +86,7 @@ xtts_base_url: http://localhost:8020
|
|||||||
xtts_use_deepspeed: false
|
xtts_use_deepspeed: false
|
||||||
xtts_use_streaming_mode: true
|
xtts_use_streaming_mode: true
|
||||||
auto_read: false
|
auto_read: false
|
||||||
current_voice: null
|
xtts_current_voice: null
|
||||||
xtts_current_language: en
|
xtts_current_language: en
|
||||||
|
|
||||||
# Image generation service
|
# Image generation service
|
||||||
@ -145,17 +145,15 @@ audio_silenceTimer: 5000
|
|||||||
# Data vectorization
|
# Data vectorization
|
||||||
activate_skills_lib: false # Activate vectorizing previous conversations
|
activate_skills_lib: false # Activate vectorizing previous conversations
|
||||||
skills_lib_database_name: "default" # Default skills database
|
skills_lib_database_name: "default" # Default skills database
|
||||||
summerize_discussion: false # activate discussion summary (better but adds computation time)
|
|
||||||
|
|
||||||
max_summary_size: 512 # in tokens
|
max_summary_size: 512 # in tokens
|
||||||
data_vectorization_visualize_on_vectorization: false
|
data_vectorization_visualize_on_vectorization: false
|
||||||
use_files: true # Activate using files
|
|
||||||
data_vectorization_activate: true # To activate/deactivate data vectorization
|
data_vectorization_activate: true # To activate/deactivate data vectorization
|
||||||
data_vectorization_method: "tfidf_vectorizer" #"model_embedding" or "tfidf_vectorizer"
|
data_vectorization_method: "tfidf_vectorizer" #"model_embedding" or "tfidf_vectorizer"
|
||||||
data_visualization_method: "PCA" #"PCA" or "TSNE"
|
data_visualization_method: "PCA" #"PCA" or "TSNE"
|
||||||
data_vectorization_sentense_transformer_model: "all-MiniLM-L6-v2" # you can use another model by setting its name here or its path
|
data_vectorization_sentense_transformer_model: "all-MiniLM-L6-v2" # you can use another model by setting its name here or its path
|
||||||
|
|
||||||
data_vectorization_save_db: false # For each new session, new files
|
data_vectorization_save_db: true # For each new session, new files
|
||||||
data_vectorization_chunk_size: 512 # chunk size
|
data_vectorization_chunk_size: 512 # chunk size
|
||||||
data_vectorization_overlap_size: 128 # overlap between chunks size
|
data_vectorization_overlap_size: 128 # overlap between chunks size
|
||||||
data_vectorization_nb_chunks: 2 # number of chunks to use
|
data_vectorization_nb_chunks: 2 # number of chunks to use
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
|
||||||
version: 88
|
version: 90
|
||||||
binding_name: null
|
binding_name: null
|
||||||
model_name: null
|
model_name: null
|
||||||
model_variant: null
|
model_variant: null
|
||||||
@ -86,7 +86,7 @@ xtts_base_url: http://localhost:8020
|
|||||||
xtts_use_deepspeed: false
|
xtts_use_deepspeed: false
|
||||||
xtts_use_streaming_mode: true
|
xtts_use_streaming_mode: true
|
||||||
auto_read: false
|
auto_read: false
|
||||||
current_voice: null
|
xtts_current_voice: null
|
||||||
xtts_current_language: en
|
xtts_current_language: en
|
||||||
|
|
||||||
# Image generation service
|
# Image generation service
|
||||||
@ -145,11 +145,9 @@ audio_silenceTimer: 5000
|
|||||||
# Data vectorization
|
# Data vectorization
|
||||||
activate_skills_lib: false # Activate vectorizing previous conversations
|
activate_skills_lib: false # Activate vectorizing previous conversations
|
||||||
skills_lib_database_name: "default" # Default skills database
|
skills_lib_database_name: "default" # Default skills database
|
||||||
summerize_discussion: false # activate discussion summary (better but adds computation time)
|
|
||||||
|
|
||||||
max_summary_size: 512 # in tokens
|
max_summary_size: 512 # in tokens
|
||||||
data_vectorization_visualize_on_vectorization: false
|
data_vectorization_visualize_on_vectorization: false
|
||||||
use_files: true # Activate using files
|
|
||||||
data_vectorization_activate: true # To activate/deactivate data vectorization
|
data_vectorization_activate: true # To activate/deactivate data vectorization
|
||||||
data_vectorization_method: "tfidf_vectorizer" #"model_embedding" or "tfidf_vectorizer"
|
data_vectorization_method: "tfidf_vectorizer" #"model_embedding" or "tfidf_vectorizer"
|
||||||
data_visualization_method: "PCA" #"PCA" or "TSNE"
|
data_visualization_method: "PCA" #"PCA" or "TSNE"
|
||||||
|
@ -55,11 +55,48 @@ def switch_personal_path(data:PersonalPathParameters):
|
|||||||
|
|
||||||
|
|
||||||
@router.post("/upload_avatar")
|
@router.post("/upload_avatar")
|
||||||
@router.post("/upload_logo")
|
|
||||||
async def upload_avatar(avatar: UploadFile = File(...)):
|
async def upload_avatar(avatar: UploadFile = File(...)):
|
||||||
"""
|
"""
|
||||||
Uploads a user avatar file to a dedicated directory, preventing path traversal attacks.
|
Uploads a user avatar file to a dedicated directory, preventing path traversal attacks.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- avatar: UploadFile object representing the user avatar file.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
- Dictionary with the status of the upload and the generated file name.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
- HTTPException with a 400 status code and an error message if the file is invalid or has an invalid type.
|
||||||
|
"""
|
||||||
|
# Only allow certain file types
|
||||||
|
if avatar.filename.endswith((".jpg", ".png")):
|
||||||
|
# Create a random file name
|
||||||
|
random_filename = str(uuid.uuid4())
|
||||||
|
|
||||||
|
# Use the file extension of the uploaded file
|
||||||
|
extension = os.path.splitext(avatar.filename)[1]
|
||||||
|
|
||||||
|
# Create the new file path in a dedicated directory
|
||||||
|
file_location = os.path.join(lollmsElfServer.lollms_paths.personal_user_infos_path, f"{random_filename}{extension}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Open the image to check if it's a valid image
|
||||||
|
img = Image.open(avatar.file)
|
||||||
|
|
||||||
|
# Save the file
|
||||||
|
img.save(file_location)
|
||||||
|
except Exception as e:
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid image file.")
|
||||||
|
else:
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid file type.")
|
||||||
|
|
||||||
|
return {"status": True,"fileName": f"{random_filename}{extension}"}
|
||||||
|
|
||||||
|
@router.post("/upload_logo")
|
||||||
|
async def upload_logo(avatar: UploadFile = File(...)):
|
||||||
|
"""
|
||||||
|
Uploads a user avatar file to a dedicated directory, preventing path traversal attacks.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
- avatar: UploadFile object representing the user avatar file.
|
- avatar: UploadFile object representing the user avatar file.
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ async def set_voice(request: Request):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
data = (await request.json())
|
data = (await request.json())
|
||||||
lollmsElfServer.config.current_voice=data["voice"]
|
lollmsElfServer.config.xtts_current_voice=data["voice"]
|
||||||
if lollmsElfServer.config.auto_save:
|
if lollmsElfServer.config.auto_save:
|
||||||
lollmsElfServer.config.save_config()
|
lollmsElfServer.config.save_config()
|
||||||
return {"status":True}
|
return {"status":True}
|
||||||
@ -106,7 +106,7 @@ async def text2Audio(request: LollmsText2AudioRequest):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
return {"url": None, "error":f"{ex}"}
|
return {"url": None, "error":f"{ex}"}
|
||||||
|
|
||||||
voice=lollmsElfServer.config.current_voice if request.voice is None else request.voice
|
voice=lollmsElfServer.config.xtts_current_voice if request.voice is None else request.voice
|
||||||
index = find_first_available_file_index(lollmsElfServer.tts.output_folder, "voice_sample_",".wav")
|
index = find_first_available_file_index(lollmsElfServer.tts.output_folder, "voice_sample_",".wav")
|
||||||
output_fn=f"voice_sample_{index}.wav" if request.fn is None else request.fn
|
output_fn=f"voice_sample_{index}.wav" if request.fn is None else request.fn
|
||||||
if voice is None:
|
if voice is None:
|
||||||
@ -133,9 +133,12 @@ async def text2Audio(request: LollmsText2AudioRequest):
|
|||||||
voice_file = [v for v in voices_folder.iterdir() if v.stem==voice]
|
voice_file = [v for v in voices_folder.iterdir() if v.stem==voice]
|
||||||
if len(voice_file)==0:
|
if len(voice_file)==0:
|
||||||
return {"status":False,"error":"Voice not found"}
|
return {"status":False,"error":"Voice not found"}
|
||||||
|
if not lollmsElfServer.config.xtts_use_streaming_mode:
|
||||||
lollmsElfServer.tts.tts_to_file(preprocessed_text, voice_file[0].name, f"{output_fn}", language=language)
|
lollmsElfServer.tts.tts_to_file(preprocessed_text, voice_file[0].name, f"{output_fn}", language=language)
|
||||||
lollmsElfServer.info(f"Voice file ready at {url}")
|
lollmsElfServer.info(f"Voice file ready at {url}")
|
||||||
|
else:
|
||||||
|
lollmsElfServer.tts.tts_to_audio(preprocessed_text, voice_file[0].name, f"{output_fn}", language=language)
|
||||||
|
|
||||||
return {"url": url}
|
return {"url": url}
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
trace_exception(ex)
|
trace_exception(ex)
|
||||||
@ -205,7 +208,7 @@ async def upload_voice_file(file: UploadFile = File(...)):
|
|||||||
safe_file_path = lollmsElfServer.lollms_paths.custom_voices_path/safe_filename
|
safe_file_path = lollmsElfServer.lollms_paths.custom_voices_path/safe_filename
|
||||||
with safe_file_path.open("wb") as f:
|
with safe_file_path.open("wb") as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
lollmsElfServer.config.current_voice=safe_filename
|
lollmsElfServer.config.xtts_current_voice=safe_filename
|
||||||
if lollmsElfServer.config.auto_save:
|
if lollmsElfServer.config.auto_save:
|
||||||
lollmsElfServer.config.save_config()
|
lollmsElfServer.config.save_config()
|
||||||
|
|
||||||
|
@ -167,9 +167,9 @@ class LollmsXTTS:
|
|||||||
ASCIIColors.yellow("Loading XTTS ")
|
ASCIIColors.yellow("Loading XTTS ")
|
||||||
options= ""
|
options= ""
|
||||||
if self.use_deep_speed:
|
if self.use_deep_speed:
|
||||||
options += "--deepspeed"
|
options += " --deepspeed"
|
||||||
if self.use_streaming_mode:
|
if self.use_streaming_mode:
|
||||||
options += "--streaming-mode --streaming-mode-improve --stream-play-sync"
|
options += " --streaming-mode --streaming-mode-improve --stream-play-sync"
|
||||||
process = run_python_script_in_env("xtts", f"-m xtts_api_server {options} -o {self.output_folder} -sf {self.voice_samples_path} -p {self.xtts_base_url.split(':')[-1].replace('/','')}", wait= False)
|
process = run_python_script_in_env("xtts", f"-m xtts_api_server {options} -o {self.output_folder} -sf {self.voice_samples_path} -p {self.xtts_base_url.split(':')[-1].replace('/','')}", wait= False)
|
||||||
return process
|
return process
|
||||||
|
|
||||||
@ -237,6 +237,30 @@ class LollmsXTTS:
|
|||||||
# Send the POST request
|
# Send the POST request
|
||||||
response = requests.post(url, headers=headers, data=json.dumps(payload))
|
response = requests.post(url, headers=headers, data=json.dumps(payload))
|
||||||
|
|
||||||
|
# Check the response status code
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("Request successful")
|
||||||
|
# You can access the response data using response.json()
|
||||||
|
else:
|
||||||
|
print("Request failed with status code:", response.status_code)
|
||||||
|
|
||||||
|
def tts_to_audio(self, text, speaker_wav, file_name_or_path, language="en"):
|
||||||
|
url = f"{self.xtts_base_url}/tts_to_audio"
|
||||||
|
|
||||||
|
# Define the request body
|
||||||
|
payload = {
|
||||||
|
"text": text,
|
||||||
|
"speaker_wav": speaker_wav,
|
||||||
|
"language": language
|
||||||
|
}
|
||||||
|
headers = {
|
||||||
|
'accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send the POST request
|
||||||
|
response = requests.post(url, headers=headers, data=json.dumps(payload))
|
||||||
|
|
||||||
# Check the response status code
|
# Check the response status code
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
print("Request successful")
|
print("Request successful")
|
||||||
|
@ -81,7 +81,7 @@ copy_to_clipboard_add_all_details: false
|
|||||||
enable_voice_service: false
|
enable_voice_service: false
|
||||||
xtts_base_url: http://localhost:8020
|
xtts_base_url: http://localhost:8020
|
||||||
auto_read: false
|
auto_read: false
|
||||||
current_voice: null
|
xtts_current_voice: null
|
||||||
xtts_current_language: en
|
xtts_current_language: en
|
||||||
|
|
||||||
# Image generation service
|
# Image generation service
|
||||||
|
Loading…
Reference in New Issue
Block a user