This commit is contained in:
saloui 2023-12-11 16:48:48 +01:00
parent 2c84cb9b31
commit 21985dc2bb
5 changed files with 54 additions and 8 deletions

View File

@ -184,11 +184,12 @@ class LoLLMsAPI(LollmsApplication):
except: except:
self.webcam = None self.webcam = None
try: try:
rec_output_folder = lollms_paths.personal_outputs_path/"audio_rec" self.rec_output_folder = lollms_paths.personal_outputs_path/"audio_rec"
rec_output_folder.mkdir(exist_ok=True, parents=True) self.rec_output_folder.mkdir(exist_ok=True, parents=True)
self.audio_cap = AudioRecorder(socketio,rec_output_folder/"rt.wav",lollmsCom=self) self.summoned = False
self.audio_cap = AudioRecorder(socketio,self.rec_output_folder/"rt.wav", callback=self.audio_callback,lollmsCom=self)
except: except:
rec_output_folder = None self.rec_output_folder = None
# ========================================================================================= # =========================================================================================
# Socket IO stuff # Socket IO stuff
# ========================================================================================= # =========================================================================================
@ -1012,7 +1013,52 @@ class LoLLMsAPI(LollmsApplication):
ASCIIColors.blue(f"Your personal data is stored here :",end="") ASCIIColors.blue(f"Your personal data is stored here :",end="")
ASCIIColors.green(f"{self.lollms_paths.personal_path}") ASCIIColors.green(f"{self.lollms_paths.personal_path}")
def audio_callback(self, text):
if self.summoned:
client_id = 0
self.cancel_gen = False
self.connections[client_id]["generated_text"]=""
self.connections[client_id]["cancel_generation"]=False
self.connections[client_id]["continuing"]=False
self.connections[client_id]["first_chunk"]=True
if not self.model:
ASCIIColors.error("Model not selected. Please select a model")
self.error("Model not selected. Please select a model", client_id=client_id)
return
if not self.busy:
if self.connections[client_id]["current_discussion"] is None:
if self.db.does_last_discussion_have_messages():
self.connections[client_id]["current_discussion"] = self.db.create_discussion()
else:
self.connections[client_id]["current_discussion"] = self.db.load_last_discussion()
prompt = text
ump = self.config.discussion_prompt_separator +self.config.user_name.strip() if self.config.use_user_name_in_discussions else self.personality.user_message_prefix
message = self.connections[client_id]["current_discussion"].add_message(
message_type = MSG_TYPE.MSG_TYPE_FULL.value,
sender_type = SENDER_TYPES.SENDER_TYPES_USER.value,
sender = ump.replace(self.config.discussion_prompt_separator,"").replace(":",""),
content=prompt,
metadata=None,
parent_message_id=self.message_id
)
ASCIIColors.green("Starting message generation by "+self.personality.name)
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message.id, client_id))
self.connections[client_id]['generation_thread'].start()
self.socketio.sleep(0.01)
ASCIIColors.info("Started generation task")
self.busy=True
#tpe = threading.Thread(target=self.start_message_generation, args=(message, message_id, client_id))
#tpe.start()
else:
self.error("I am busy. Come back later.", client_id=client_id)
else:
if text.lower()=="lollms":
self.summoned = True
def rebuild_personalities(self, reload_all=False): def rebuild_personalities(self, reload_all=False):
if reload_all: if reload_all:
self.mounted_personalities=[] self.mounted_personalities=[]

@ -1 +1 @@
Subproject commit 150e7f325106412f4d46d9bdbda93b4c205aa51b Subproject commit 2e77d696ded386d7ead9393425a024565a7a97d7

@ -1 +1 @@
Subproject commit 937482007a2d7b74a5e1a13e798b427c2fb56592 Subproject commit b43d25d13a4614ff4281ebeb157c8be952562475

@ -1 +1 @@
Subproject commit 0de6d1784abdf73deff0e392c18252fefde8dd0f Subproject commit 2f6f4ca2fd8b5b8889c792095ba5b65b920c175e

@ -1 +1 @@
Subproject commit 1cd2af0014c2424996261d7b0bfe7d3f74d16412 Subproject commit 9d6231e2eb20c444a6005e48ea9fceac07629ec2