Update lollms_generation_events.py

This commit is contained in:
Saifeddine ALOUI 2024-05-22 15:55:43 +02:00 committed by GitHub
parent 14c8ec09b4
commit 353abdf1d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,7 +36,7 @@ lollmsElfServer = LOLLMSWebUI.get_instance()
def add_events(sio:socketio): def add_events(sio:socketio):
forbid_remote_access(lollmsElfServer) forbid_remote_access(lollmsElfServer)
@sio.on('generate_msg') @sio.on('generate_msg')
def handle_generate_msg(sid, data): def handle_generate_msg(sid, data, use_threading=True):
client_id = sid client_id = sid
lollmsElfServer.cancel_gen = False lollmsElfServer.cancel_gen = False
client = lollmsElfServer.session.get_client(client_id) client = lollmsElfServer.session.get_client(client_id)
@ -78,9 +78,12 @@ def add_events(sio:socketio):
) )
ASCIIColors.green("Starting message generation by "+lollmsElfServer.personality.name) ASCIIColors.green("Starting message generation by "+lollmsElfServer.personality.name)
client.generation_thread = threading.Thread(target=lollmsElfServer.start_message_generation, args=(message, message.id, client_id)) if use_threading:
client.generation_thread.start() client.generation_thread = threading.Thread(target=lollmsElfServer.start_message_generation, args=(message, message.id, client_id))
client.generation_thread.start()
else:
lollmsElfServer.start_message_generation(message, message.id, client_id)
# lollmsElfServer.sio.sleep(0.01) # lollmsElfServer.sio.sleep(0.01)
ASCIIColors.info("Started generation task") ASCIIColors.info("Started generation task")
lollmsElfServer.busy=True lollmsElfServer.busy=True
@ -195,4 +198,4 @@ def add_events(sio:socketio):
#add functions to lollm #add functions to lollm
lollmsElfServer.handle_generate_msg = handle_generate_msg lollmsElfServer.handle_generate_msg = handle_generate_msg
lollmsElfServer.generate_msg_with_internet = generate_msg_with_internet lollmsElfServer.generate_msg_with_internet = generate_msg_with_internet
lollmsElfServer.handle_continue_generate_msg_from = handle_continue_generate_msg_from lollmsElfServer.handle_continue_generate_msg_from = handle_continue_generate_msg_from