From 5ba8df51d4963faeff93950e159e0f3f5c1d7b98 Mon Sep 17 00:00:00 2001 From: Damjan Date: Fri, 27 Dec 2024 16:41:46 +0100 Subject: [PATCH] Update code snippets for adding new tools --- guides/add_your_own_tool.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/guides/add_your_own_tool.md b/guides/add_your_own_tool.md index 67f7772..ba7a7c6 100644 --- a/guides/add_your_own_tool.md +++ b/guides/add_your_own_tool.md @@ -104,6 +104,10 @@ if (customTool) { const result = await customTool._call("your-input"); console.log(result); } + +// or alternatively +const result = await agent.customFunction("your-input"); // assuming you have a `customFunction` method in SolanaAgentKit +console.log(result); ``` ## Best Practices @@ -170,6 +174,21 @@ export class SolanaAgentKit { } ``` +Then it can be used as such: + +```typescript +import { SolanaAgentKit } from "solana-agent-kit"; + +const agent = new SolanaAgentKit( + "your-wallet-private-key-as-base58", + "https://api.mainnet-beta.solana.com", + "your-openai-api-key" +); + +const result = await agent.getTokenPrice("SOL"); +console.log(result); +``` + ## Need Help? If you encounter any issues while implementing your custom tool: