mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-19 04:37:54 +00:00
integrating the full audio communication with the discussions system
This commit is contained in:
parent
536663047c
commit
5e0f38da1b
@ -19,7 +19,7 @@ from pathlib import Path
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
from socketio import AsyncServer
|
||||
from typing import Tuple, List
|
||||
from typing import Tuple, List, Dict
|
||||
import subprocess
|
||||
import importlib
|
||||
import sys, os
|
||||
@ -66,6 +66,12 @@ class LollmsApplication(LoLLMsCom):
|
||||
self.skills_library = SkillsLibrary(self.lollms_paths.personal_skills_path/(self.config.skills_lib_database_name+".db"))
|
||||
|
||||
self.tasks_library = TasksLibrary(self)
|
||||
|
||||
self.handle_generate_msg: Callable[[str, Dict], None] = None
|
||||
self.generate_msg_with_internet: Callable[[str, Dict], None] = None
|
||||
self.handle_continue_generate_msg_from: Callable[[str, Dict], None] = None
|
||||
|
||||
|
||||
if not free_mode:
|
||||
try:
|
||||
if config.auto_update:
|
||||
|
@ -89,7 +89,7 @@ from lollms.tasks import TasksLibrary
|
||||
from lollms.tts import LollmsTTS
|
||||
from lollms.personality import AIPersonality
|
||||
from lollms.function_call import FunctionCalling_Library
|
||||
from lollms.databases.discussions_database import Discussion, DiscussionsDB
|
||||
from lollms.client_session import Client
|
||||
from datetime import datetime
|
||||
|
||||
import math
|
||||
@ -100,11 +100,11 @@ class AudioRecorder:
|
||||
lc:LollmsApplication,
|
||||
sio:socketio.Client,
|
||||
personality:AIPersonality,
|
||||
discussion_database:DiscussionsDB,
|
||||
client:Client,
|
||||
threshold=1000, silence_duration=2, sound_threshold_percentage=10, gain=1.0, rate=44100, channels=1, buffer_size=10, model="small.en", snd_device=None, logs_folder="logs", voice=None, block_while_talking=True, context_size=4096):
|
||||
self.sio = sio
|
||||
self.lc = lc
|
||||
self.discussion_database = discussion_database
|
||||
self.client = client
|
||||
self.tts = LollmsTTS(self.lc)
|
||||
self.tl = TasksLibrary(self.lc)
|
||||
self.fn = FunctionCalling_Library(self.tl)
|
||||
@ -176,7 +176,6 @@ class AudioRecorder:
|
||||
self.model = model
|
||||
self.whisper = whisper.load_model(model)
|
||||
ASCIIColors.success("OK")
|
||||
self.discussion = discussion_database.create_discussion("RT_chat")
|
||||
|
||||
def get_date_time(self):
|
||||
now = datetime.now()
|
||||
@ -364,26 +363,16 @@ class AudioRecorder:
|
||||
self.transcribed_files.append((filename, result["text"]))
|
||||
self.transcribed_lock.notify()
|
||||
if result["text"]!="":
|
||||
current_prompt = result["text"]
|
||||
# TODO : send the output
|
||||
# self.transcription_signal.new_user_transcription.emit(filename, result["text"])
|
||||
self.discussion.add_message(MSG_TYPE.MSG_TYPE_FULL.value, SENDER_TYPES.SENDER_TYPES_USER.value, user_name, result["text"])
|
||||
discussion = self.discussion.format_discussion(self.context_size)
|
||||
full_context = self.personality.personality_conditioning + user_description +"\n" + discussion+f"\n!@>{self.personality.name}:"
|
||||
ASCIIColors.red(" ---------------- Discussion ---------------------")
|
||||
ASCIIColors.yellow(full_context)
|
||||
ASCIIColors.red(" -------------------------------------------------")
|
||||
# TODO : send the output
|
||||
# self.transcription_signal.update_status.emit("Generating answer")
|
||||
ASCIIColors.green("<<RESPONDING>>")
|
||||
lollms_text, function_calls =self.fn.generate_with_functions(full_context)
|
||||
if len(function_calls)>0:
|
||||
responses = self.fn.execute_function_calls(function_calls=function_calls)
|
||||
if self.image_shot:
|
||||
lollms_text = self.tl.fast_gen_with_images(full_context+f"!@>{self.personality.name}: "+ lollms_text + "\n!@>functions outputs:\n"+ "\n".join(responses) +"!@>lollms:", [self.image_shot])
|
||||
else:
|
||||
lollms_text = self.tl.fast_gen(full_context+f"!@>{self.personality.name}: "+ lollms_text + "\n!@>functions outputs:\n"+ "\n".join(responses) +"!@>lollms:")
|
||||
lollms_text = self.fix_string_for_xtts(lollms_text)
|
||||
self.discussion.add_message(MSG_TYPE.MSG_TYPE_FULL.value, SENDER_TYPES.SENDER_TYPES_AI.value, self.personality.name,lollms_text)
|
||||
self.lc.handle_generate_msg(self.client.client_id, {"prompt": current_prompt})
|
||||
while self.lc.busy:
|
||||
time.sleep(0.01)
|
||||
lollms_text = self.fix_string_for_xtts(self.client.generated_text)
|
||||
ASCIIColors.red(" -------------- LOLLMS answer -------------------")
|
||||
ASCIIColors.yellow(lollms_text)
|
||||
ASCIIColors.red(" -------------------------------------------------")
|
||||
|
@ -47,7 +47,7 @@ class LOLLMSElfServer(LollmsApplication):
|
||||
)
|
||||
return LOLLMSElfServer.__instance
|
||||
@staticmethod
|
||||
def get_instance():
|
||||
def get_instance()->'LOLLMSElfServer':
|
||||
return LOLLMSElfServer.__instance
|
||||
|
||||
def __init__(
|
||||
|
@ -298,9 +298,9 @@ async def upload_voice_file(file: UploadFile = File(...)):
|
||||
return {"message": f"Successfully uploaded {safe_filename}"}
|
||||
|
||||
|
||||
@router.get("/xtts_is_ready")
|
||||
def xtts_is_ready():
|
||||
if hasattr(lollmsElfServer,'sd') and lollmsElfServer.sd is not None:
|
||||
if lollmsElfServer.sd.ready:
|
||||
@router.get("/tts_is_ready")
|
||||
def tts_is_ready():
|
||||
if lollmsElfServer.tts:
|
||||
if lollmsElfServer.tts.ready:
|
||||
return {"status":True}
|
||||
return {"status":False}
|
||||
|
Loading…
Reference in New Issue
Block a user