From 64b6ea4e962aedbcefc232e39f41d5342331d8e0 Mon Sep 17 00:00:00 2001 From: dtrckd Date: Thu, 30 May 2024 18:14:44 +0200 Subject: [PATCH 1/4] hotfix: fix #45 --- app/commands.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/commands.py b/app/commands.py index 7e887f0..6fa2366 100755 --- a/app/commands.py +++ b/app/commands.py @@ -55,7 +55,7 @@ def is_valid_command(self, command): ] def get_help(self, config: Config) -> str: - cmds = self._get_cmds() + cmds = self._get_cmds(config) model_url = f"https://huggingface.co/{config.albert_model_name}" model_short_name = config.albert_model_name.split("/")[-1] @@ -93,14 +93,14 @@ def show_commands(self): available_cmd += "- " + "\n- ".join(cmds) return available_cmd - def _get_cmds(self): - cmds = [ - feature["help"] - for name, feature in self.function_register.items() - if name in self.activated_functions and feature["help"] - and not (feature.get("command") == "sources" && config.albert_mode == "norag") - ] - return cmds + def _get_cmds(self, config): + cmds = [ + feature["help"] + for name, feature in self.function_register.items() + if name in self.activated_functions and feature["help"] + and not (feature.get("command") == "sources" and config.albert_mode == "norag") + ] + return cmds command_registry = CommandRegistry({}, set()) @@ -227,11 +227,11 @@ async def albert_mode(ep: EventParser, matrix_client: MatrixClient): all_modes = get_available_modes(config) all_modes += ["norag"] if len(commands) <= 1: - message = f"La commande !mode nécessite de donner un mode parmi : {", ".join(all_modes)}" + message = f"La commande !mode nécessite de donner un mode parmi : {', '.join(all_modes)}" else: mode = commands[1] if mode not in all_modes: - message = f"Mode inconnu. Les modes disponibles sont : {", ".join(all_modes)}" + message = f"Mode inconnu. Les modes disponibles sont : {', '.join(all_modes)}" else: old_mode = config.albert_mode config.albert_mode = mode From 2c670831766e62e62624e09f93b52e4a57c31b4f Mon Sep 17 00:00:00 2001 From: dtrckd Date: Thu, 30 May 2024 18:27:55 +0200 Subject: [PATCH 2/4] hotfix: pass config to all help commands --- app/commands.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/commands.py b/app/commands.py index 6fa2366..1320d38 100755 --- a/app/commands.py +++ b/app/commands.py @@ -87,8 +87,8 @@ def get_help(self, config: Config) -> str: return help_message - def show_commands(self): - cmds = self._get_cmds() + def show_commands(self, config: Config): + cmds = self._get_cmds(config) available_cmd = "Les commandes spéciales suivantes sont disponibles :\n\n" available_cmd += "- " + "\n- ".join(cmds) return available_cmd @@ -97,7 +97,8 @@ def _get_cmds(self, config): cmds = [ feature["help"] for name, feature in self.function_register.items() - if name in self.activated_functions and feature["help"] + if name in self.activated_functions + and feature["help"] and not (feature.get("command") == "sources" and config.albert_mode == "norag") ] return cmds @@ -318,11 +319,12 @@ async def albert_answer(ep: EventParser, matrix_client: MatrixClient): help=None, ) async def albert_wrong_command(ep: EventParser, matrix_client: MatrixClient): + config = user_configs[ep.sender] user_prompt = ep.event.body command = user_prompt.split()[0][1:] if not user_prompt.startswith(COMMAND_PREFIX) or command_registry.is_valid_command(command): raise EventNotConcerned await matrix_client.send_markdown_message( ep.room.room_id, - f"\u26a0\ufe0f **Commande inconnue**\n\n{command_registry.show_commands()}", + f"\u26a0\ufe0f **Commande inconnue**\n\n{command_registry.show_commands(config)}", ) From a679035460cada249614db93e07c2871ba64a65d Mon Sep 17 00:00:00 2001 From: Adrien Carpentier Date: Thu, 30 May 2024 22:50:34 +0200 Subject: [PATCH 3/4] fix: fix !sources command help --- app/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/commands.py b/app/commands.py index 1320d38..b5aa06a 100755 --- a/app/commands.py +++ b/app/commands.py @@ -244,7 +244,7 @@ async def albert_mode(ep: EventParser, matrix_client: MatrixClient): group="albert", onEvent=RoomMessageText, command="sources", - help=f"Pour obtenir les sources utilisées pour générer mes réponses, utilisez **{COMMAND_PREFIX}sources**", + help=f"Pour obtenir les sources utilisées pour générer ma dernière réponse, utilisez **{COMMAND_PREFIX}sources**", ) async def albert_sources(ep: EventParser, matrix_client: MatrixClient): config = user_configs[ep.sender] From eb7e051d634dcaeb8ff746a2e62065fe60ee6883 Mon Sep 17 00:00:00 2001 From: Adrien Carpentier Date: Fri, 31 May 2024 13:34:41 +0200 Subject: [PATCH 4/4] feat: mode command available for all albert deployments --- app/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/commands.py b/app/commands.py index b5aa06a..8e6def5 100755 --- a/app/commands.py +++ b/app/commands.py @@ -215,7 +215,7 @@ async def albert_debug(ep: EventParser, matrix_client: MatrixClient): @register_feature( - group="albert_debug", + group="albertfeat", onEvent=RoomMessageText, command="mode", help=f"Pour modifier le mode du modèle (c'est-à-dire le modèle de prompt utilisé), utilisez **{COMMAND_PREFIX}mode** MODE",