Improve command system; add aliases for commands (#2635)

* Command name supports multiple names

* Separate CommandRegistry.commands and .command_aliases

* Update test_commands.py

* Add __contains__ operator to CommandRegistry

* Update error message for unknown commands

---------

Co-authored-by: Reinier van der Leer <github@pwuts.nl>
This commit is contained in:
lengweiping1983
2023-07-08 23:29:55 +08:00
committed by GitHub
parent 8bce02736b
commit 8b8b3a2cdd
12 changed files with 278 additions and 293 deletions

View File

@@ -8,17 +8,16 @@ def check_plan():
def test_execute_command_plugin(agent: Agent):
"""Test that executing a command that came from a plugin works as expected"""
command_name = "check_plan"
agent.ai_config.prompt_generator.add_command(
"check_plan",
command_name,
"Read the plan.md with the next goals to achieve",
{},
check_plan,
)
command_name = "check_plan"
arguments = {}
command_result = execute_command(
command_name=command_name,
arguments=arguments,
arguments={},
agent=agent,
)
assert command_result == "hi"