mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
run_async
This commit is contained in:
parent
fc63abaebb
commit
e3bc03a0ab
@ -1 +1 @@
|
||||
Subproject commit c7ca64c5c8351631adae352d6a0cb250b7aa137f
|
||||
Subproject commit d0368bdb2dadcab350bc8a533a74e3b9fd9e8f07
|
@ -20,7 +20,7 @@ from lollms.paths import LollmsPaths
|
||||
from lollms.helpers import ASCIIColors, trace_exception
|
||||
from lollms.com import NotificationType, NotificationDisplayType, LoLLMsCom
|
||||
from lollms.app import LollmsApplication
|
||||
from lollms.utilities import File64BitsManager, PromptReshaper, PackageManager, find_first_available_file_index, run_async
|
||||
from lollms.utilities import File64BitsManager, PromptReshaper, PackageManager, find_first_available_file_index, run_async, is_asyncio_loop_running
|
||||
import git
|
||||
import asyncio
|
||||
import os
|
||||
@ -962,7 +962,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
verbose=True,
|
||||
):
|
||||
|
||||
run_async(
|
||||
asyncio.run(
|
||||
self.socketio.emit('notification', {
|
||||
'content': content,# self.connections[client_id]["generated_text"],
|
||||
'notification_type': notification_type.value,
|
||||
@ -1010,52 +1010,31 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
model = self.config["model_name"],
|
||||
personality = self.config["personalities"][self.config["active_personality_id"]],
|
||||
) # first the content is empty, but we'll fill it at the end
|
||||
try:
|
||||
self.socketio.emit('new_message',
|
||||
{
|
||||
"sender": sender,
|
||||
"message_type": message_type.value,
|
||||
"sender_type": SENDER_TYPES.SENDER_TYPES_AI.value,
|
||||
"content": content,
|
||||
"parameters": parameters,
|
||||
"metadata": metadata,
|
||||
"ui": ui,
|
||||
"id": msg.id,
|
||||
"parent_message_id": msg.parent_message_id,
|
||||
run_async(partial(
|
||||
self.socketio.emit,'new_message',
|
||||
{
|
||||
"sender": sender,
|
||||
"message_type": message_type.value,
|
||||
"sender_type": SENDER_TYPES.SENDER_TYPES_AI.value,
|
||||
"content": content,
|
||||
"parameters": parameters,
|
||||
"metadata": metadata,
|
||||
"ui": ui,
|
||||
"id": msg.id,
|
||||
"parent_message_id": msg.parent_message_id,
|
||||
|
||||
'binding': self.config["binding_name"],
|
||||
'model' : self.config["model_name"],
|
||||
'personality': self.config["personalities"][self.config["active_personality_id"]],
|
||||
'binding': self.config["binding_name"],
|
||||
'model' : self.config["model_name"],
|
||||
'personality': self.config["personalities"][self.config["active_personality_id"]],
|
||||
|
||||
'created_at': self.connections[client_id]["current_discussion"].current_message.created_at,
|
||||
'finished_generating_at': self.connections[client_id]["current_discussion"].current_message.finished_generating_at,
|
||||
'created_at': self.connections[client_id]["current_discussion"].current_message.created_at,
|
||||
'finished_generating_at': self.connections[client_id]["current_discussion"].current_message.finished_generating_at,
|
||||
|
||||
'open': open
|
||||
}, to=client_id
|
||||
'open': open
|
||||
}, to=client_id
|
||||
)
|
||||
)
|
||||
except:
|
||||
asyncio.run(self.socketio.emit('new_message',
|
||||
{
|
||||
"sender": sender,
|
||||
"message_type": message_type.value,
|
||||
"sender_type": SENDER_TYPES.SENDER_TYPES_AI.value,
|
||||
"content": content,
|
||||
"parameters": parameters,
|
||||
"metadata": metadata,
|
||||
"ui": ui,
|
||||
"id": msg.id,
|
||||
"parent_message_id": msg.parent_message_id,
|
||||
|
||||
'binding': self.config["binding_name"],
|
||||
'model' : self.config["model_name"],
|
||||
'personality': self.config["personalities"][self.config["active_personality_id"]],
|
||||
|
||||
'created_at': self.connections[client_id]["current_discussion"].current_message.created_at,
|
||||
'finished_generating_at': self.connections[client_id]["current_discussion"].current_message.finished_generating_at,
|
||||
|
||||
'open': open
|
||||
}, to=client_id
|
||||
))
|
||||
|
||||
def update_message(self, client_id, chunk,
|
||||
parameters=None,
|
||||
metadata=[],
|
||||
@ -1065,7 +1044,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
self.connections[client_id]["current_discussion"].current_message.finished_generating_at=datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
mtdt = json.dumps(metadata, indent=4) if metadata is not None and type(metadata)== list else metadata
|
||||
if self.nb_received_tokens==1:
|
||||
run_async(
|
||||
asyncio.run(
|
||||
self.socketio.emit('update_message', {
|
||||
"sender": self.personality.name,
|
||||
'id':self.connections[client_id]["current_discussion"].current_message.id,
|
||||
@ -1080,7 +1059,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
)
|
||||
)
|
||||
|
||||
run_async(
|
||||
asyncio.run(
|
||||
self.socketio.emit('update_message', {
|
||||
"sender": self.personality.name,
|
||||
'id':self.connections[client_id]["current_discussion"].current_message.id,
|
||||
@ -1106,7 +1085,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
self.connections[client_id]["generated_text"]=self.connections[client_id]["generated_text"].split("!@>")[0]
|
||||
# Send final message
|
||||
self.connections[client_id]["current_discussion"].current_message.finished_generating_at=datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
run_async(
|
||||
asyncio.run(
|
||||
self.socketio.emit('close_message', {
|
||||
"sender": self.personality.name,
|
||||
"id": self.connections[client_id]["current_discussion"].current_message.id,
|
||||
@ -1164,7 +1143,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
if message_type == MSG_TYPE.MSG_TYPE_NEW_MESSAGE:
|
||||
self.nb_received_tokens = 0
|
||||
self.start_time = datetime.now()
|
||||
run_async(
|
||||
asyncio.run(
|
||||
self.new_message(
|
||||
client_id,
|
||||
self.personality.name if personality is None else personality.name,
|
||||
@ -1443,7 +1422,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
if ttl is None or ttl=="" or ttl=="untitled":
|
||||
title = self.make_discussion_title(d, client_id=client_id)
|
||||
d.rename(title)
|
||||
run_async(
|
||||
asyncio.run(
|
||||
self.socketio.emit('disucssion_renamed',{
|
||||
'status': True,
|
||||
'discussion_id':d.discussion_id,
|
||||
|
Loading…
Reference in New Issue
Block a user