added creation and update date to personalities

This commit is contained in:
Saifeddine ALOUI 2024-09-01 22:53:35 +02:00
parent 9aaa79e4a1
commit 2dce9311fa
3 changed files with 11 additions and 19 deletions

View File

@ -654,16 +654,6 @@ class LollmsApplication(LoLLMsCom):
return model
def mount_extension(self, id:int, callback=None):
try:
extension = ExtensionBuilder().build_extension(self.config["extensions"][id], self.lollms_paths, self)
self.mounted_extensions.append(extension)
return extension
except Exception as ex:
ASCIIColors.error(f"Couldn't load extension. Please verify your configuration file at {self.lollms_paths.personal_configuration_path} or use the next menu to select a valid personality")
trace_exception(ex)
return None
def mount_personality(self, id:int, callback=None):
try:

View File

@ -468,16 +468,14 @@ class RTCom:
voices = self.lc.tts.get_voices() # Assuming the response is in JSON format
return voices
return []
from pathlib import Path
import os
import sounddevice as sd
import threading
import datetime
import wave
class AudioNinja:
def __init__(self, lc:LollmsApplication, logs_folder='logs', device=None):
def __init__(self, lc, logs_folder='logs', device=None):
"""
Initialize the AudioNinja with a LollmsApplication object,
a log folder, and an optional recording device.
@ -493,8 +491,11 @@ class AudioNinja:
self.recording_thread = None
self.is_recording = False
self.frames = []
if not self.logs_folder.exists():
self.logs_folder.mkdir(parents=True, exist_ok=True)
self.sample_rate = 44100 # Default sample rate
self.channels = 1 # Default to mono recording
# Ensure the logs folder exists
self.logs_folder.mkdir(parents=True, exist_ok=True)
self.lc.info(f"AudioNinja is ready to strike from the shadows! Logging to '{self.logs_folder}' with device '{self.device}'")
def _record_audio(self):
@ -505,7 +506,7 @@ class AudioNinja:
if self.is_recording:
self.frames.append(indata.copy())
with sd.InputStream(callback=callback, device=self.device):
with sd.InputStream(callback=callback, device=self.device, channels=self.channels, samplerate=self.sample_rate):
while self.is_recording:
sd.sleep(1000)
@ -538,9 +539,9 @@ class AudioNinja:
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
filename = self.logs_folder / f"recording_{timestamp}.wav"
with wave.open(filename, 'wb') as wf:
wf.setnchannels(1)
wf.setnchannels(self.channels)
wf.setsampwidth(sd.default.dtype[0].itemsize)
wf.setframerate(44100)
wf.setframerate(self.sample_rate)
wf.writeframes(b''.join(self.frames))
self.lc.info(f"Ninja stored the audio file at '{filename}'! 🥷📂")
return filename

View File

@ -93,9 +93,10 @@ def get_all_personalities():
personality_info['name'] = config_data.get('name',"No Name")
personality_info['description'] = config_data.get('personality_description',"")
personality_info['disclaimer'] = config_data.get('disclaimer',"")
personality_info['author'] = config_data.get('author', 'ParisNeo')
personality_info['version'] = config_data.get('version', '1.0.0')
personality_info['creation_date'] = config_data.get("creation_date",None)
personality_info['last_update_date'] = config_data.get("last_update_date",None)
personality_info['installed'] = (lollmsElfServer.lollms_paths.personal_configuration_path/f"personality_{personality_folder.stem}.yaml").exists() or personality_info['has_scripts']
personality_info['help'] = config_data.get('help', '')
personality_info['commands'] = config_data.get('commands', '')