Custom Tools
What is a Custom Tool?
In the Eko framework, Tools are core components that implement different functionalities. Built-in Tools provide some basic functions, such as WebSearch Tool for web searching. However, real-world application scenarios vary, and different applications may need specific functionalities to meet their requirements. This is where custom Tools come in.
Custom Tools allow developers to design and implement their own function modules based on specific business logic or application needs, without relying on built-in tools. Through custom Tools, developers can extend the capabilities of the Eko framework and enhance its flexibility and adaptability.
Why Custom Tools?
Custom Tools help developers solve the following problems:
- When existing Tools cannot meet specific needs, custom Tools can be created to implement them.
- Developers can customize input and output structures to adapt to application requirements based on business logic complexity.
- Modularize repeated functionality for easier management and debugging.
- Call internal company services and integrate specific business logic.
How to Custom Tools in Eko?
Each Tool needs to implement the following core elements:
name
: Unique identifier for the Tooldescription
: Functional description of the Toolinput_schema
: Input parameter structure definitionexecute
: Specific execution logic
To create custom Tools in Eko, you need to follow these steps:
- Define input and output structures: Clearly specify the Tool’s input parameters and output results.
- Implement Tool interface: Inherit or implement the
Tool
interface and define related properties and methods. - Handle parameters: Write implementation logic for specific functionality in the
execute
method.
Creating a Custom Tool
Let’s explain how to create a custom Tool through a simple example.
Suppose we want to create an email sending Tool: