This repository has been archived by the owner on Sep 13, 2023. It is now read-only.
Addition of Ability Register and Sample Ability #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, we have introduced an AbilityRegister class and a sample ability. The AbilityRegister is designed to manage and execute abilities, which are essentially callable methods with metadata.
The AbilityRegister class has the following key methods:
register_abilities: This method scans the abilities directory and imports all Python files as modules. It then checks each module for functions that have been decorated with the ability decorator and adds them to the register.
list_abilities: This method returns a list of all registered abilities.
abilities_description: This method returns a string representation of all registered abilities, grouped by category.
run_ability: This method executes a specified ability with the provided arguments and keyword arguments.
The ability decorator is used to annotate functions that should be treated as abilities. It takes the following parameters: name, description, parameters, and output_type. The decorator checks that the function's parameters match the provided parameters and then attaches an Ability instance to the function.
The Ability class represents an ability in the system. It includes metadata about the ability such as its name, description, parameters, and output type. The Ability class can be called like a function, executing the underlying method.
A sample ability has been added to demonstrate how to create an ability. More abilities can be added by creating new Python files in the abilities directory and using the ability decorator to annotate functions.
This new feature enhances the modularity and extensibility of our system, allowing new abilities to be added easily and in a structured manner.