@composio/llamaindex 0.10.0 → 0.10.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -212
- package/dist/index.d.mts +3 -4
- package/dist/index.mjs +3 -3
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -1,154 +1,18 @@
|
|
|
1
1
|
# @composio/llamaindex
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Seamless LlamaIndex Integration**: Tools are automatically compatible with LlamaIndex agents and workflows
|
|
8
|
-
- **Full Modifier Support**: Support for both schema and execution modifiers with beforeExecute/afterExecute hooks
|
|
9
|
-
- **Streaming Support**: Works with LlamaIndex streaming agents using `agentStreamEvent`
|
|
10
|
-
- **Tool Execution**: Execute tools with proper parameter handling and JSON schema validation
|
|
11
|
-
- **Type Safety**: Full TypeScript support with proper type definitions
|
|
12
|
-
- **Zod Schema Integration**: Automatic conversion from JSON Schema to Zod for LlamaIndex compatibility
|
|
3
|
+
The LlamaIndex provider turns Composio tools into LlamaIndex tools that execute themselves, ready to hand to a LlamaIndex agent.
|
|
13
4
|
|
|
14
5
|
## Installation
|
|
15
6
|
|
|
16
7
|
```bash
|
|
17
|
-
npm install @composio/llamaindex
|
|
18
|
-
# or
|
|
19
|
-
yarn add @composio/llamaindex
|
|
20
|
-
# or
|
|
21
|
-
pnpm add @composio/llamaindex
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Quick Start
|
|
25
|
-
|
|
26
|
-
```typescript
|
|
27
|
-
import { Composio } from '@composio/core';
|
|
28
|
-
import { LlamaindexProvider } from '@composio/llamaindex';
|
|
29
|
-
|
|
30
|
-
// Initialize Composio with Llamaindex provider
|
|
31
|
-
const composio = new Composio({
|
|
32
|
-
apiKey: 'your-composio-api-key',
|
|
33
|
-
provider: new LlamaindexProvider(),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// Get available tools
|
|
37
|
-
const tools = await composio.tools.get('user123', {
|
|
38
|
-
toolkits: ['gmail', 'googlecalendar'],
|
|
39
|
-
limit: 10,
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Prerequisites
|
|
44
|
-
|
|
45
|
-
Before using the LlamaIndex provider, make sure you have:
|
|
46
|
-
|
|
47
|
-
1. **Composio API Key**: Get your API key from [Composio Dashboard](https://app.composio.dev)
|
|
48
|
-
2. **Environment Setup**: Set up your environment variables
|
|
49
|
-
3. **LlamaIndex Dependencies**: Install required LlamaIndex packages
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
# Install LlamaIndex dependencies
|
|
53
|
-
npm install @llamaindex/openai @llamaindex/workflow
|
|
8
|
+
npm install @composio/core @composio/llamaindex @llamaindex/openai @llamaindex/workflow
|
|
54
9
|
```
|
|
55
10
|
|
|
56
|
-
|
|
57
|
-
# Set up environment variables
|
|
58
|
-
export COMPOSIO_API_KEY="your-composio-api-key"
|
|
59
|
-
export OPENAI_API_KEY="your-openai-api-key" # For LlamaIndex OpenAI integration
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Usage Examples
|
|
63
|
-
|
|
64
|
-
### Basic Example
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
import { Composio } from '@composio/core';
|
|
68
|
-
import { LlamaindexProvider } from '@composio/llamaindex';
|
|
69
|
-
|
|
70
|
-
// Initialize Composio
|
|
71
|
-
const composio = new Composio({
|
|
72
|
-
apiKey: process.env.COMPOSIO_API_KEY,
|
|
73
|
-
provider: new LlamaindexProvider(),
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Get tools
|
|
77
|
-
const tools = await composio.tools.get('default', {
|
|
78
|
-
toolkits: ['gmail'],
|
|
79
|
-
limit: 10,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
console.log(`Found ${tools.length} tools`);
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Complete Agent Example with HackerNews
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
import { Composio } from '@composio/core';
|
|
89
|
-
import { LlamaindexProvider } from '@composio/llamaindex';
|
|
90
|
-
import { openai } from '@llamaindex/openai';
|
|
91
|
-
import { agent, agentStreamEvent } from '@llamaindex/workflow';
|
|
92
|
-
import 'dotenv/config';
|
|
93
|
-
|
|
94
|
-
// Initialize Composio with LlamaIndex provider
|
|
95
|
-
const composio = new Composio({
|
|
96
|
-
apiKey: process.env.COMPOSIO_API_KEY,
|
|
97
|
-
provider: new LlamaindexProvider(),
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
async function main() {
|
|
101
|
-
try {
|
|
102
|
-
console.log('🚀 Starting LlamaIndex Example...');
|
|
103
|
-
|
|
104
|
-
// Get available tools with modifiers
|
|
105
|
-
const tools = await composio.tools.get(
|
|
106
|
-
'default',
|
|
107
|
-
{
|
|
108
|
-
toolkits: ['hackernews'],
|
|
109
|
-
limit: 10,
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
|
|
113
|
-
console.log(`🔄 Executing tool ${toolSlug}/${toolkitSlug} with params:`, { params });
|
|
114
|
-
return params;
|
|
115
|
-
},
|
|
116
|
-
afterExecute: ({ toolSlug, toolkitSlug, result }) => {
|
|
117
|
-
console.log(`✅ Executed tool ${toolSlug}/${toolkitSlug} with result:`, { result });
|
|
118
|
-
return result;
|
|
119
|
-
},
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
console.log(`✅ Found ${tools.length} tools`);
|
|
11
|
+
Set `COMPOSIO_API_KEY` with your API key from [the dashboard](https://dashboard.composio.dev/settings), and `OPENAI_API_KEY` (or your LLM provider's key).
|
|
124
12
|
|
|
125
|
-
|
|
126
|
-
const hackernewsAgent = agent({
|
|
127
|
-
name: 'Hackernews Agent',
|
|
128
|
-
description: 'A helpful hackernews assistant',
|
|
129
|
-
llm: openai({ model: 'gpt-4o-mini' }),
|
|
130
|
-
systemPrompt:
|
|
131
|
-
'You are a helpful hackernews assistant that helps users with their queries related to hackernews',
|
|
132
|
-
tools, // Composio tools are automatically compatible with LlamaIndex
|
|
133
|
-
});
|
|
13
|
+
## Quickstart
|
|
134
14
|
|
|
135
|
-
|
|
136
|
-
const stream = await hackernewsAgent.runStream('Summarize the front page of hackernews');
|
|
137
|
-
|
|
138
|
-
for await (const event of stream) {
|
|
139
|
-
if (agentStreamEvent.include(event)) {
|
|
140
|
-
process.stdout.write(event.data.delta);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error('❌ Error running example:', error);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
main().catch(console.error);
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Using Tools with Different Toolkits
|
|
15
|
+
Create a session for your user, fetch its tools, and hand them to an agent:
|
|
152
16
|
|
|
153
17
|
```typescript
|
|
154
18
|
import { Composio } from '@composio/core';
|
|
@@ -157,87 +21,28 @@ import { openai } from '@llamaindex/openai';
|
|
|
157
21
|
import { agent } from '@llamaindex/workflow';
|
|
158
22
|
|
|
159
23
|
const composio = new Composio({
|
|
160
|
-
apiKey: process.env.COMPOSIO_API_KEY,
|
|
161
24
|
provider: new LlamaindexProvider(),
|
|
162
25
|
});
|
|
163
26
|
|
|
164
|
-
//
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
limit: 20,
|
|
168
|
-
});
|
|
27
|
+
// Create a session for your user
|
|
28
|
+
const session = await composio.create('user_123');
|
|
29
|
+
const tools = await session.tools();
|
|
169
30
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
name: 'Personal Assistant',
|
|
173
|
-
description: 'A helpful personal assistant',
|
|
174
|
-
llm: openai({ model: 'gpt-4' }),
|
|
175
|
-
systemPrompt:
|
|
176
|
-
'You are a helpful personal assistant that can manage emails, calendar events, and slack messages.',
|
|
31
|
+
const myAgent = agent({
|
|
32
|
+
llm: openai({ model: 'gpt-5.2' }),
|
|
177
33
|
tools,
|
|
178
34
|
});
|
|
179
35
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
'Schedule a meeting for tomorrow at 2 PM and send a slack message about it'
|
|
36
|
+
const result = await myAgent.run(
|
|
37
|
+
"Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'"
|
|
183
38
|
);
|
|
184
|
-
console.log(response);
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## API Reference
|
|
188
|
-
|
|
189
|
-
### LlamaindexProvider Class
|
|
190
|
-
|
|
191
|
-
The `LlamaindexProvider` class extends `BaseAgenticProvider` and provides llamaindex-specific functionality.
|
|
192
|
-
|
|
193
|
-
#### Methods
|
|
194
39
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
Wraps a single Composio tool in the LlamaIndex format with proper Zod schema conversion.
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
const llamaindexTool = provider.wrapTool(composioTool, executeTool);
|
|
201
|
-
|
|
202
|
-
// The wrapped tool has LlamaIndex-compatible structure:
|
|
203
|
-
// - metadata.name: Tool slug
|
|
204
|
-
// - metadata.description: Tool description
|
|
205
|
-
// - metadata.parameters: Zod schema for parameters
|
|
206
|
-
// - call(): Function to execute the tool
|
|
40
|
+
console.log(result.data.result);
|
|
207
41
|
```
|
|
208
42
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
Wraps multiple Composio tools for use with LlamaIndex agents.
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
const llamaindexTools = provider.wrapTools(composioTools, executeTool);
|
|
215
|
-
|
|
216
|
-
// Use directly with LlamaIndex agents
|
|
217
|
-
const agent = agent({
|
|
218
|
-
name: 'My Agent',
|
|
219
|
-
llm: openai({ model: 'gpt-4' }),
|
|
220
|
-
tools: llamaindexTools, // Ready to use!
|
|
221
|
-
});
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
##### `wrapMcpServerResponse(data: McpUrlResponse): McpServerGetResponse`
|
|
225
|
-
|
|
226
|
-
Transforms MCP URL responses into the standard format with URL objects.
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
const mcpServers = provider.wrapMcpServerResponse(urlResponse);
|
|
230
|
-
// Returns: [{ url: URL, name: string }, ...]
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## Contributing
|
|
234
|
-
|
|
235
|
-
We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
|
|
236
|
-
|
|
237
|
-
## License
|
|
238
|
-
|
|
239
|
-
ISC License
|
|
43
|
+
The provider converts each tool's JSON Schema parameters to Zod and wires execution through Composio, so LlamaIndex can call the tools directly.
|
|
240
44
|
|
|
241
|
-
##
|
|
45
|
+
## Links
|
|
242
46
|
|
|
243
|
-
|
|
47
|
+
- [LlamaIndex provider docs](https://docs.composio.dev/docs/providers/llamaindex)
|
|
48
|
+
- [Composio documentation](https://docs.composio.dev)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BaseAgenticProvider, ExecuteToolFn, McpServerGetResponse, McpUrlResponse, Tool } from "@composio/core";
|
|
2
2
|
import { tool } from "llamaindex";
|
|
3
|
-
|
|
4
3
|
//#region src/index.d.ts
|
|
5
4
|
type LlamaindexTool = ReturnType<typeof tool>;
|
|
6
5
|
type LlamaindexToolCollection = Array<LlamaindexTool>;
|
|
@@ -19,9 +18,9 @@ declare class LlamaindexProvider extends BaseAgenticProvider<Array<LlamaindexToo
|
|
|
19
18
|
*/
|
|
20
19
|
wrapTools(tools: Tool[], executeTool: ExecuteToolFn): LlamaindexToolCollection;
|
|
21
20
|
/**
|
|
22
|
-
* Transform MCP URL response into
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Transform an MCP URL response into the LlamaIndex provider's format.
|
|
22
|
+
* LlamaIndex uses the standard MCP server response shape, mapping each
|
|
23
|
+
* entry to an object with a `URL` instance and its name.
|
|
25
24
|
*
|
|
26
25
|
* @param data - The MCP URL response data
|
|
27
26
|
* @returns Standard MCP server response format
|
package/dist/index.mjs
CHANGED
|
@@ -39,9 +39,9 @@ var LlamaindexProvider = class extends BaseAgenticProvider {
|
|
|
39
39
|
return tools.map((tool) => this.wrapTool(tool, executeTool));
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Transform MCP URL response into
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* Transform an MCP URL response into the LlamaIndex provider's format.
|
|
43
|
+
* LlamaIndex uses the standard MCP server response shape, mapping each
|
|
44
|
+
* entry to an object with a `URL` instance and its name.
|
|
45
45
|
*
|
|
46
46
|
* @param data - The MCP URL response data
|
|
47
47
|
* @returns Standard MCP server response format
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/llamaindex",
|
|
3
|
-
"version": "0.10.0",
|
|
3
|
+
"version": "0.10.2-beta.0",
|
|
4
4
|
"description": "Agentic Provider for llamaindex in Composio SDK",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.22.3"
|
|
9
|
+
},
|
|
7
10
|
"repository": {
|
|
8
11
|
"type": "git",
|
|
9
12
|
"url": "https://github.com/ComposioHQ/composio.git",
|
|
@@ -12,7 +15,7 @@
|
|
|
12
15
|
"bugs": {
|
|
13
16
|
"url": "https://github.com/ComposioHQ/composio/issues"
|
|
14
17
|
},
|
|
15
|
-
"homepage": "https://github.com/ComposioHQ/composio/tree/
|
|
18
|
+
"homepage": "https://github.com/ComposioHQ/composio/tree/next/ts/packages/providers/llamaindex#readme",
|
|
16
19
|
"publishConfig": {
|
|
17
20
|
"access": "public"
|
|
18
21
|
},
|
|
@@ -34,13 +37,13 @@
|
|
|
34
37
|
"author": "",
|
|
35
38
|
"license": "ISC",
|
|
36
39
|
"peerDependencies": {
|
|
37
|
-
"@composio/core": ">=0.
|
|
40
|
+
"@composio/core": ">=1.0.0-beta.0 <2.0.0",
|
|
38
41
|
"llamaindex": "^0.12.0"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
|
-
"tsdown": "^0.22.
|
|
42
|
-
"typescript": "^
|
|
43
|
-
"@composio/core": "0.
|
|
44
|
+
"tsdown": "^0.22.14",
|
|
45
|
+
"typescript": "^7.0.2",
|
|
46
|
+
"@composio/core": "1.0.0-beta.0"
|
|
44
47
|
},
|
|
45
48
|
"scripts": {
|
|
46
49
|
"build": "tsdown",
|