From 353abdf1d93531552db4efc0b9ee310daf254635 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Wed, 22 May 2024 15:55:43 +0200 Subject: [PATCH] Update lollms_generation_events.py --- events/lollms_generation_events.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/events/lollms_generation_events.py b/events/lollms_generation_events.py index 22a15de3..73ae4a68 100644 --- a/events/lollms_generation_events.py +++ b/events/lollms_generation_events.py @@ -36,7 +36,7 @@ lollmsElfServer = LOLLMSWebUI.get_instance() def add_events(sio:socketio): forbid_remote_access(lollmsElfServer) @sio.on('generate_msg') - def handle_generate_msg(sid, data): + def handle_generate_msg(sid, data, use_threading=True): client_id = sid lollmsElfServer.cancel_gen = False 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) - client.generation_thread = threading.Thread(target=lollmsElfServer.start_message_generation, args=(message, message.id, client_id)) - client.generation_thread.start() - + if use_threading: + 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) ASCIIColors.info("Started generation task") lollmsElfServer.busy=True @@ -195,4 +198,4 @@ def add_events(sio:socketio): #add functions to lollm lollmsElfServer.handle_generate_msg = handle_generate_msg lollmsElfServer.generate_msg_with_internet = generate_msg_with_internet - lollmsElfServer.handle_continue_generate_msg_from = handle_continue_generate_msg_from \ No newline at end of file + lollmsElfServer.handle_continue_generate_msg_from = handle_continue_generate_msg_from