rubyllm_tool_support - MadBomber/aia GitHub Wiki
RubyLLM::Tool Support
AIA supports function calling capabilities through the RubyLLM::Tool
framework, enabling LLMs to execute custom functions during a chat session.
What Are RubyLLM Tools?
Tools (or functions) allow LLMs to perform actions beyond generating text, such as:
- Retrieving real-time information
- Executing system commands
- Accessing external APIs
- Performing calculations
Check out the examples/tools directory which contains several ready-to-use tool implementations you can use as references.
How to Use Tools
AIA provides three CLI options to manage function calling:
--tools
Option
Specifies where to find tool implementations:
# Load tools from multiple sources
--tools /path/to/tools/directory,other/tools/dir,my_tool.rb
# Or use multiple --tools flags
--tools my_first_tool.rb --tools /tool_repo/tools
Each path can be:
- A Ruby file implementing a
RubyLLM::Tool
subclass - A directory containing tool implementations (all Ruby files in that directory will be loaded)
Supporting files for tools can be placed in the same directory or subdirectories.
Filtering the tool paths
The --tools option must have exact relative or absolute paths to the tool files to be used by AIA for function callbacks. If you are specifying directories you may find yourself needing filter the entire set of tools to either allow some or reject others based upon some indicator in their file name. The following two options allow you to specify multiple sub-strings to match the tolls paths against. For example you might be comparing one version of a tool against another. Their filenames could have version prefixes like tool_v1.rb and tool_v2.rb Using the allowed and rejected filters you can choose one of the other when using an entire directory full of tools.
--at
, --allowed_tools
Option
Filters which tools to make available when loading from directories:
# Only allow tools with 'test' in their filename
--tools my_tools_directory --allowed_tools test
This is useful when you have many tools but only want to use specific ones in a session.
--rt
, --rejected_tools
Option
Excludes specific tools:
# Exclude tools with '_v1' in their filename
--tools my_tools_directory --rejected_tools _v1
Ideal for excluding older versions or temporarily disabling specific tools.
Creating Your Own Tools
To create a custom tool:
- Create a Ruby file that subclasses
RubyLLM::Tool
- Define the tool's parameters and functionality
- Use the
--tools
option to load it in your AIA session
For implementation details, refer to the examples in the repository or the RubyLLM documentation.