useTools
useTools(
options:object):UseToolsResult
Defined in: src/react/useTools.ts:84
React hook for fetching and caching server-side tools.
This hook provides:
- Automatic fetching of tools on mount
- Caching with localStorage persistence
- Checksum-based cache invalidation
- Automatic refresh when tools change on the server
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
Whether to fetch tools automatically on mount (default: true) |
|
|
|
Optional base URL for the API requests. |
|
|
() => |
Custom function to get auth token for API calls |
|
|
|
Filter to include only specific tools by name.
|
Returns
Example
const { tools, checkForUpdates, refresh } = useTools({
getToken: async () => authToken,
});
// After sending a message, check if tools need refresh
const result = await sendMessage({ messages, model });
checkForUpdates(result.toolsChecksum);Last updated on