From 37eaf7e9f1ca1ece8f702f23b7bc64afd03406e3 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sat, 15 Jul 2023 20:06:26 +0200 Subject: [PATCH] upgraded --- lollms/personality.py | 17 +++++++++++------ setup.py | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lollms/personality.py b/lollms/personality.py index 801a04a..2836e33 100644 --- a/lollms/personality.py +++ b/lollms/personality.py @@ -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. @@ -886,17 +886,21 @@ class StateMachine: Raises: 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] commands = current_state["commands"] + command = command.strip() - for cmd, func in commands: - if cmd == command: - func() + for cmd, func in commands.items(): + if cmd == command[0:len(cmd)]: + func(command) return default_func = current_state.get("default") if default_func is not None: - default_func() + default_func(command) else: raise ValueError(f"Command '{command}' not found in current state and no default function defined.") @@ -970,7 +974,8 @@ class APScript(StateMachine): ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*") - def add_file(self, path): + def add_file(self, path, callback=None): + self.callback=callback self.files.append(path) return True diff --git a/setup.py b/setup.py index f5cda48..bffd247 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="2.1.36", + version="2.1.38", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition",