mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-21 21:47:54 +00:00
upgraded personas
This commit is contained in:
parent
c8bb03e71d
commit
0f21c67086
@ -1720,7 +1720,7 @@ class StateMachine:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def process_state(self, command, full_context, callback: Callable[[str, MSG_TYPE, dict, list], bool]=None):
|
def process_state(self, command, full_context, callback: Callable[[str, MSG_TYPE, dict, list], bool]=None, client:Client=None):
|
||||||
"""
|
"""
|
||||||
Process the given command based on the current state.
|
Process the given command based on the current state.
|
||||||
|
|
||||||
@ -1739,7 +1739,10 @@ class StateMachine:
|
|||||||
|
|
||||||
for cmd, func in commands.items():
|
for cmd, func in commands.items():
|
||||||
if cmd == command[0:len(cmd)]:
|
if cmd == command[0:len(cmd)]:
|
||||||
func(command, full_context)
|
try:
|
||||||
|
func(command, full_context,client)
|
||||||
|
except:# retrocompatibility
|
||||||
|
func(command, full_context)
|
||||||
return
|
return
|
||||||
|
|
||||||
default_func = current_state.get("default")
|
default_func = current_state.get("default")
|
||||||
@ -1923,7 +1926,7 @@ class APScript(StateMachine):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def execute_command(self, command: str, parameters:list=[]):
|
def execute_command(self, command: str, parameters:list=[], client:Client=None):
|
||||||
"""
|
"""
|
||||||
Recovers user commands and executes them. Each personality can define a set of commands that they can receive and execute
|
Recovers user commands and executes them. Each personality can define a set of commands that they can receive and execute
|
||||||
Args:
|
Args:
|
||||||
@ -1932,7 +1935,7 @@ class APScript(StateMachine):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.process_state(command, "", self.callback)
|
self.process_state(command, "", self.callback, client)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
trace_exception(ex)
|
trace_exception(ex)
|
||||||
self.warning(f"Couldn't execute command {command}")
|
self.warning(f"Couldn't execute command {command}")
|
||||||
@ -2246,7 +2249,8 @@ class APScript(StateMachine):
|
|||||||
f"!@>summary:",
|
f"!@>summary:",
|
||||||
f"{answer_start}"
|
f"{answer_start}"
|
||||||
]),
|
]),
|
||||||
max_generation_size=max_generation_size, callback=callback)
|
max_generation_size=max_generation_size,
|
||||||
|
callback=callback)
|
||||||
summeries.append(summary)
|
summeries.append(summary)
|
||||||
return "\n".join(summeries)
|
return "\n".join(summeries)
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ from functools import partial
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
|
from lollms.security import check_access
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
lollmsElfServer = LOLLMSElfServer.get_instance()
|
lollmsElfServer = LOLLMSElfServer.get_instance()
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ def add_events(sio:socketio):
|
|||||||
@sio.on('execute_command')
|
@sio.on('execute_command')
|
||||||
def execute_command(sid, data):
|
def execute_command(sid, data):
|
||||||
client_id = sid
|
client_id = sid
|
||||||
client = lollmsElfServer.session.get_client(client_id)
|
client = check_access(lollmsElfServer, client_id)
|
||||||
|
|
||||||
lollmsElfServer.cancel_gen = False
|
lollmsElfServer.cancel_gen = False
|
||||||
client.generated_text=""
|
client.generated_text=""
|
||||||
@ -153,7 +153,7 @@ def add_events(sio:socketio):
|
|||||||
if lollmsElfServer.personality.processor is not None:
|
if lollmsElfServer.personality.processor is not None:
|
||||||
lollmsElfServer.start_time = datetime.now()
|
lollmsElfServer.start_time = datetime.now()
|
||||||
lollmsElfServer.personality.processor.callback = partial(lollmsElfServer.process_chunk, client_id=client_id)
|
lollmsElfServer.personality.processor.callback = partial(lollmsElfServer.process_chunk, client_id=client_id)
|
||||||
lollmsElfServer.personality.processor.execute_command(command, parameters)
|
lollmsElfServer.personality.processor.execute_command(command, parameters, client)
|
||||||
else:
|
else:
|
||||||
lollmsElfServer.warning("Non scripted personalities do not support commands",client_id=client_id)
|
lollmsElfServer.warning("Non scripted personalities do not support commands",client_id=client_id)
|
||||||
lollmsElfServer.close_message(client_id)
|
lollmsElfServer.close_message(client_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user