Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 04:45 UTC
| 1 | import { Composio } from '@composio/core'; |
| 2 | import { VercelProvider } from '@composio/vercel'; |
| 3 | |
| 4 | /** |
| 5 | * Non agentic provider |
| 6 | */ |
| 7 | const composio = new Composio({ |
| 8 | apiKey: process.env.COMPOSIO_API_KEY, |
| 9 | }); |
| 10 | |
| 11 | const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', { |
| 12 | // toolkit slug too |
| 13 | modifySchema: ({ toolSlug, toolkitSlug, schema }) => { |
| 14 | if (toolSlug === 'HACKERNEWS_GET_USER') { |
| 15 | schema = { |
| 16 | ...schema, |
| 17 | inputParameters: { |
| 18 | type: 'object', |
| 19 | properties: { |
| 20 | ...schema.inputParameters?.properties, |
| 21 | userId: { |
| 22 | type: 'string', |
| 23 | description: 'The user ID to get the user for', |
| 24 | }, |
| 25 | }, |
| 26 | }, |
| 27 | }; |
| 28 | } |
| 29 | |
| 30 | return schema; |
| 31 | }, |
| 32 | }); |
| 33 | |
| 34 | console.log(tools); |
| 35 | |
| 36 | /** |
| 37 | * Agentic provider |
| 38 | */ |
| 39 | const vercel = new Composio({ |
| 40 | apiKey: process.env.COMPOSIO_API_KEY, |
| 41 | // calling this provider now no? or what? or toolProvider or toolManager? |
| 42 | provider: new VercelProvider(), |
| 43 | }); |
| 44 | |
| 45 | const agenticTools = await vercel.tools.get( |
| 46 | 'default', |
| 47 | // what is the type error i am getting here? |
| 48 | { tools: ['HACKERNEWS_GET_USER'] }, |
| 49 | { |
| 50 | afterExecute: ({ toolSlug, toolkitSlug, result }) => { |
| 51 | // modify the result |
| 52 | return result; |
| 53 | }, |
| 54 | beforeExecute: ({ toolSlug, toolkitSlug, params }) => { |
| 55 | // modify the params |
| 56 | return params; |
| 57 | }, |
| 58 | modifySchema: ({ toolSlug, toolkitSlug, schema }) => { |
| 59 | // modify the tool schema |
| 60 | return schema; |
| 61 | }, |
| 62 | } |
| 63 | ); |
| 64 | |
| 65 | console.log(agenticTools); |