From 9aef34cd81e2c6015adb4b11729fa3e73b735c3b Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Wed, 16 Aug 2023 03:31:14 +0200 Subject: [PATCH] Added callbacks to personalities --- lollms/personality.py | 27 +++++++++++++++++++++++++++ setup.py | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lollms/personality.py b/lollms/personality.py index 084e6a2..0cf83ca 100644 --- a/lollms/personality.py +++ b/lollms/personality.py @@ -1140,6 +1140,9 @@ class APScript(StateMachine): step_text (str): The step text callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step start to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(step_text, MSG_TYPE.MSG_TYPE_STEP_START) @@ -1150,6 +1153,9 @@ class APScript(StateMachine): step_text (str): The step text callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step end to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(step_text, MSG_TYPE.MSG_TYPE_STEP_END, {'status':status}) @@ -1160,6 +1166,9 @@ class APScript(StateMachine): step_text (str): The step text callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(step_text, MSG_TYPE.MSG_TYPE_STEP) @@ -1170,6 +1179,9 @@ class APScript(StateMachine): step_text (str): The step text callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(str(ex), MSG_TYPE.MSG_TYPE_EXCEPTION) @@ -1180,6 +1192,9 @@ class APScript(StateMachine): step_text (str): The step text callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(warning, MSG_TYPE.MSG_TYPE_EXCEPTION) @@ -1190,6 +1205,9 @@ class APScript(StateMachine): inf (str): The information to be sent callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(info, MSG_TYPE.MSG_TYPE_INFO) @@ -1200,6 +1218,9 @@ class APScript(StateMachine): step_text (dict): The step text callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(json.dumps(json_infos, indent=indent), MSG_TYPE.MSG_TYPE_JSON_INFOS) @@ -1210,6 +1231,9 @@ class APScript(StateMachine): step_text (dict): The step text callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(html_ui, MSG_TYPE.MSG_TYPE_UI) @@ -1220,6 +1244,9 @@ class APScript(StateMachine): step_text (dict): The step text callback (callable, optional): A callable with this signature (str, MSG_TYPE) to send the step to. Defaults to None. """ + if not callback and self.callback: + callback = self.callback + if callback: callback(code, MSG_TYPE.MSG_TYPE_CODE) diff --git a/setup.py b/setup.py index a084f66..0676bfa 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="2.3.1", + version="2.3.2", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition",