Tools
Tools enable Hydra to interact with your application's data and functionality. They provide a type-safe way to extend the AI's capabilities with custom business logic. Hydra will call these tools and use their outputs to help decide how to respond to a message, what component to show, and what data to fill the component with.
To make use of tools, we will:
- Add tools by defining them and registering them with Hydra
- Associate tools with components, so Hydra know which tools to focus on when using a given component
Adding a Tool
Registering a Tool using React Hooks:
Associating Tools with Components
Once Hydra has decided on a component to use in response to a message, it will use the registered tools if it has decided that extra external data is needed to fill the component properly. To tell Hydra which tools to consider for a given component, we need to associate the tools with the component. A tool can be associated with multiple components.
During component definition:
If you already have the tool functionality defined when you register your components, you can pass the tool directly to the component definition.
Using React Hooks:
If you define your tool functionality sometime after registering your components, you can use the addToolAssociation
hook to associate the tool with the component.
Tool Definition Examples
Data Operations
File Operations
API Integration
Best Practices
- Type Safety
- Error Handling
- Documentation