This commit is contained in:
Saifeddine ALOUI 2023-07-15 20:06:26 +02:00
parent 6a9ce589a2
commit 37eaf7e9f1
2 changed files with 12 additions and 7 deletions

View File

@ -876,7 +876,7 @@ class StateMachine:
def process_state(self, command): def process_state(self, command, callback=None):
""" """
Process the given command based on the current state. Process the given command based on the current state.
@ -886,17 +886,21 @@ class StateMachine:
Raises: Raises:
ValueError: If the current state doesn't have the command and no default function is defined. ValueError: If the current state doesn't have the command and no default function is defined.
""" """
if callback:
self.callback=callback
current_state = self.states_dict[self.current_state_id] current_state = self.states_dict[self.current_state_id]
commands = current_state["commands"] commands = current_state["commands"]
command = command.strip()
for cmd, func in commands: for cmd, func in commands.items():
if cmd == command: if cmd == command[0:len(cmd)]:
func() func(command)
return return
default_func = current_state.get("default") default_func = current_state.get("default")
if default_func is not None: if default_func is not None:
default_func() default_func(command)
else: else:
raise ValueError(f"Command '{command}' not found in current state and no default function defined.") raise ValueError(f"Command '{command}' not found in current state and no default function defined.")
@ -970,7 +974,8 @@ class APScript(StateMachine):
ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*") ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
def add_file(self, path): def add_file(self, path, callback=None):
self.callback=callback
self.files.append(path) self.files.append(path)
return True return True

View File

@ -26,7 +26,7 @@ def get_all_files(path):
setuptools.setup( setuptools.setup(
name="lollms", name="lollms",
version="2.1.36", version="2.1.38",
author="Saifeddine ALOUI", author="Saifeddine ALOUI",
author_email="aloui.saifeddine@gmail.com", author_email="aloui.saifeddine@gmail.com",
description="A python library for AI personality definition", description="A python library for AI personality definition",