Creating Custom Tools
Define your own tools to extend agent capabilities.
To create a custom agent utilizing your defined tools, follow the TypeScript example below:
import { createAgent } from 'nest-ai/agents';
import { createTool } from 'nest-ai/tools';
const customTool = createTool({
name: 'Custom Tool',
execute: async (input) => {
// Custom logic here
return `Processed input: ${input}`;
},
});
const customAgent = createAgent({
tools: [customTool],
execute: async (input) => {
const toolOutput = await customTool.execute(input);
return `Agent received and processed: ${toolOutput}`;
},
});
// Usage
const input = 'Sample input';
customAgent.execute(input).then(console.log);
This creates a custom agent that uses the custom tool for processing its input, demonstrating how to extend agent capabilities effectively.
Last updated