@composio/vercel 0.1.12-alpha.14 → 0.1.12-alpha.16
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/dist/index.cjs +132 -6
- package/dist/index.d.cts +130 -6
- package/dist/index.d.ts +130 -6
- package/dist/index.js +132 -6
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -28,9 +28,77 @@ var import_ai = require("ai");
|
|
|
28
28
|
var VercelProvider = class extends import_core.BaseAgenticProvider {
|
|
29
29
|
name = "vercel";
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* Creates a new instance of the VercelProvider.
|
|
32
|
+
*
|
|
33
|
+
* This provider enables integration with the Vercel AI SDK,
|
|
34
|
+
* allowing Composio tools to be used with Vercel AI applications.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Initialize the Vercel provider
|
|
39
|
+
* const provider = new VercelProvider();
|
|
40
|
+
*
|
|
41
|
+
* // Use with Composio
|
|
42
|
+
* const composio = new Composio({
|
|
43
|
+
* apiKey: 'your-api-key',
|
|
44
|
+
* provider: new VercelProvider()
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* // Use the provider to wrap tools for Vercel AI SDK
|
|
48
|
+
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
constructor() {
|
|
52
|
+
super();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Wraps a Composio tool in a Vercel AI SDK tool format.
|
|
56
|
+
*
|
|
57
|
+
* This method transforms a Composio tool definition into the format
|
|
58
|
+
* expected by Vercel's AI SDK for function calling.
|
|
59
|
+
*
|
|
60
|
+
* @param {ComposioTool} composioTool - The Composio tool to wrap
|
|
61
|
+
* @param {ExecuteToolFn} executeTool - Function to execute the tool
|
|
62
|
+
* @returns {VercelTool} The wrapped Vercel tool
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // Wrap a single tool for use with Vercel AI SDK
|
|
67
|
+
* const composioTool = {
|
|
68
|
+
* slug: 'SEARCH_TOOL',
|
|
69
|
+
* description: 'Search for information',
|
|
70
|
+
* inputParameters: {
|
|
71
|
+
* type: 'object',
|
|
72
|
+
* properties: {
|
|
73
|
+
* query: { type: 'string' }
|
|
74
|
+
* },
|
|
75
|
+
* required: ['query']
|
|
76
|
+
* }
|
|
77
|
+
* };
|
|
78
|
+
*
|
|
79
|
+
* // Create a Vercel tool using the provider
|
|
80
|
+
* const vercelTool = provider.wrapTool(
|
|
81
|
+
* composioTool,
|
|
82
|
+
* composio.tools.execute
|
|
83
|
+
* );
|
|
84
|
+
*
|
|
85
|
+
* // Use with Vercel AI SDK
|
|
86
|
+
* import { StreamingTextResponse, Message } from 'ai';
|
|
87
|
+
* import { OpenAI } from 'openai';
|
|
88
|
+
*
|
|
89
|
+
* export async function POST(req: Request) {
|
|
90
|
+
* const { messages } = await req.json();
|
|
91
|
+
* const openai = new OpenAI();
|
|
92
|
+
*
|
|
93
|
+
* const response = await openai.chat.completions.create({
|
|
94
|
+
* model: 'gpt-4',
|
|
95
|
+
* messages,
|
|
96
|
+
* tools: [vercelTool]
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* return new StreamingTextResponse(response.choices[0].message);
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
34
102
|
*/
|
|
35
103
|
wrapTool(composioTool, executeTool) {
|
|
36
104
|
return (0, import_ai.tool)({
|
|
@@ -43,9 +111,67 @@ var VercelProvider = class extends import_core.BaseAgenticProvider {
|
|
|
43
111
|
});
|
|
44
112
|
}
|
|
45
113
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
114
|
+
* Wraps a list of Composio tools as a Vercel AI SDK tool collection.
|
|
115
|
+
*
|
|
116
|
+
* This method transforms multiple Composio tool definitions into the format
|
|
117
|
+
* expected by Vercel's AI SDK for function calling, organizing them
|
|
118
|
+
* into a dictionary keyed by tool slug.
|
|
119
|
+
*
|
|
120
|
+
* @param {ComposioTool[]} tools - Array of Composio tools to wrap
|
|
121
|
+
* @param {ExecuteToolFn} executeTool - Function to execute the tools
|
|
122
|
+
* @returns {VercelToolCollection} Dictionary of wrapped tools in Vercel AI SDK format
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Wrap multiple tools for use with Vercel AI SDK
|
|
127
|
+
* const composioTools = [
|
|
128
|
+
* {
|
|
129
|
+
* slug: 'SEARCH_TOOL',
|
|
130
|
+
* description: 'Search for information',
|
|
131
|
+
* inputParameters: {
|
|
132
|
+
* type: 'object',
|
|
133
|
+
* properties: {
|
|
134
|
+
* query: { type: 'string' }
|
|
135
|
+
* },
|
|
136
|
+
* required: ['query']
|
|
137
|
+
* }
|
|
138
|
+
* },
|
|
139
|
+
* {
|
|
140
|
+
* slug: 'WEATHER_TOOL',
|
|
141
|
+
* description: 'Get weather information',
|
|
142
|
+
* inputParameters: {
|
|
143
|
+
* type: 'object',
|
|
144
|
+
* properties: {
|
|
145
|
+
* location: { type: 'string' }
|
|
146
|
+
* },
|
|
147
|
+
* required: ['location']
|
|
148
|
+
* }
|
|
149
|
+
* }
|
|
150
|
+
* ];
|
|
151
|
+
*
|
|
152
|
+
* // Create Vercel tools using the provider
|
|
153
|
+
* const vercelTools = provider.wrapTools(
|
|
154
|
+
* composioTools,
|
|
155
|
+
* composio.tools.execute
|
|
156
|
+
* );
|
|
157
|
+
*
|
|
158
|
+
* // Use with Vercel AI SDK in a Next.js API route
|
|
159
|
+
* import { StreamingTextResponse } from 'ai';
|
|
160
|
+
* import { OpenAI } from 'openai';
|
|
161
|
+
*
|
|
162
|
+
* export async function POST(req: Request) {
|
|
163
|
+
* const { messages } = await req.json();
|
|
164
|
+
* const openai = new OpenAI();
|
|
165
|
+
*
|
|
166
|
+
* const response = await openai.chat.completions.create({
|
|
167
|
+
* model: 'gpt-4',
|
|
168
|
+
* messages,
|
|
169
|
+
* tools: Object.values(vercelTools)
|
|
170
|
+
* });
|
|
171
|
+
*
|
|
172
|
+
* return new StreamingTextResponse(response.choices[0].message);
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
49
175
|
*/
|
|
50
176
|
wrapTools(tools, executeTool) {
|
|
51
177
|
return tools.reduce((acc, tool2) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -18,15 +18,139 @@ type VercelToolCollection = Record<string, Tool>;
|
|
|
18
18
|
declare class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Tool> {
|
|
19
19
|
readonly name = "vercel";
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Creates a new instance of the VercelProvider.
|
|
22
|
+
*
|
|
23
|
+
* This provider enables integration with the Vercel AI SDK,
|
|
24
|
+
* allowing Composio tools to be used with Vercel AI applications.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Initialize the Vercel provider
|
|
29
|
+
* const provider = new VercelProvider();
|
|
30
|
+
*
|
|
31
|
+
* // Use with Composio
|
|
32
|
+
* const composio = new Composio({
|
|
33
|
+
* apiKey: 'your-api-key',
|
|
34
|
+
* provider: new VercelProvider()
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Use the provider to wrap tools for Vercel AI SDK
|
|
38
|
+
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
constructor();
|
|
42
|
+
/**
|
|
43
|
+
* Wraps a Composio tool in a Vercel AI SDK tool format.
|
|
44
|
+
*
|
|
45
|
+
* This method transforms a Composio tool definition into the format
|
|
46
|
+
* expected by Vercel's AI SDK for function calling.
|
|
47
|
+
*
|
|
48
|
+
* @param {ComposioTool} composioTool - The Composio tool to wrap
|
|
49
|
+
* @param {ExecuteToolFn} executeTool - Function to execute the tool
|
|
50
|
+
* @returns {VercelTool} The wrapped Vercel tool
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // Wrap a single tool for use with Vercel AI SDK
|
|
55
|
+
* const composioTool = {
|
|
56
|
+
* slug: 'SEARCH_TOOL',
|
|
57
|
+
* description: 'Search for information',
|
|
58
|
+
* inputParameters: {
|
|
59
|
+
* type: 'object',
|
|
60
|
+
* properties: {
|
|
61
|
+
* query: { type: 'string' }
|
|
62
|
+
* },
|
|
63
|
+
* required: ['query']
|
|
64
|
+
* }
|
|
65
|
+
* };
|
|
66
|
+
*
|
|
67
|
+
* // Create a Vercel tool using the provider
|
|
68
|
+
* const vercelTool = provider.wrapTool(
|
|
69
|
+
* composioTool,
|
|
70
|
+
* composio.tools.execute
|
|
71
|
+
* );
|
|
72
|
+
*
|
|
73
|
+
* // Use with Vercel AI SDK
|
|
74
|
+
* import { StreamingTextResponse, Message } from 'ai';
|
|
75
|
+
* import { OpenAI } from 'openai';
|
|
76
|
+
*
|
|
77
|
+
* export async function POST(req: Request) {
|
|
78
|
+
* const { messages } = await req.json();
|
|
79
|
+
* const openai = new OpenAI();
|
|
80
|
+
*
|
|
81
|
+
* const response = await openai.chat.completions.create({
|
|
82
|
+
* model: 'gpt-4',
|
|
83
|
+
* messages,
|
|
84
|
+
* tools: [vercelTool]
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* return new StreamingTextResponse(response.choices[0].message);
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
24
90
|
*/
|
|
25
91
|
wrapTool(composioTool: Tool$1, executeTool: ExecuteToolFn): Tool;
|
|
26
92
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
93
|
+
* Wraps a list of Composio tools as a Vercel AI SDK tool collection.
|
|
94
|
+
*
|
|
95
|
+
* This method transforms multiple Composio tool definitions into the format
|
|
96
|
+
* expected by Vercel's AI SDK for function calling, organizing them
|
|
97
|
+
* into a dictionary keyed by tool slug.
|
|
98
|
+
*
|
|
99
|
+
* @param {ComposioTool[]} tools - Array of Composio tools to wrap
|
|
100
|
+
* @param {ExecuteToolFn} executeTool - Function to execute the tools
|
|
101
|
+
* @returns {VercelToolCollection} Dictionary of wrapped tools in Vercel AI SDK format
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // Wrap multiple tools for use with Vercel AI SDK
|
|
106
|
+
* const composioTools = [
|
|
107
|
+
* {
|
|
108
|
+
* slug: 'SEARCH_TOOL',
|
|
109
|
+
* description: 'Search for information',
|
|
110
|
+
* inputParameters: {
|
|
111
|
+
* type: 'object',
|
|
112
|
+
* properties: {
|
|
113
|
+
* query: { type: 'string' }
|
|
114
|
+
* },
|
|
115
|
+
* required: ['query']
|
|
116
|
+
* }
|
|
117
|
+
* },
|
|
118
|
+
* {
|
|
119
|
+
* slug: 'WEATHER_TOOL',
|
|
120
|
+
* description: 'Get weather information',
|
|
121
|
+
* inputParameters: {
|
|
122
|
+
* type: 'object',
|
|
123
|
+
* properties: {
|
|
124
|
+
* location: { type: 'string' }
|
|
125
|
+
* },
|
|
126
|
+
* required: ['location']
|
|
127
|
+
* }
|
|
128
|
+
* }
|
|
129
|
+
* ];
|
|
130
|
+
*
|
|
131
|
+
* // Create Vercel tools using the provider
|
|
132
|
+
* const vercelTools = provider.wrapTools(
|
|
133
|
+
* composioTools,
|
|
134
|
+
* composio.tools.execute
|
|
135
|
+
* );
|
|
136
|
+
*
|
|
137
|
+
* // Use with Vercel AI SDK in a Next.js API route
|
|
138
|
+
* import { StreamingTextResponse } from 'ai';
|
|
139
|
+
* import { OpenAI } from 'openai';
|
|
140
|
+
*
|
|
141
|
+
* export async function POST(req: Request) {
|
|
142
|
+
* const { messages } = await req.json();
|
|
143
|
+
* const openai = new OpenAI();
|
|
144
|
+
*
|
|
145
|
+
* const response = await openai.chat.completions.create({
|
|
146
|
+
* model: 'gpt-4',
|
|
147
|
+
* messages,
|
|
148
|
+
* tools: Object.values(vercelTools)
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* return new StreamingTextResponse(response.choices[0].message);
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
30
154
|
*/
|
|
31
155
|
wrapTools(tools: Tool$1[], executeTool: ExecuteToolFn): VercelToolCollection;
|
|
32
156
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,15 +18,139 @@ type VercelToolCollection = Record<string, Tool>;
|
|
|
18
18
|
declare class VercelProvider extends BaseAgenticProvider<VercelToolCollection, Tool> {
|
|
19
19
|
readonly name = "vercel";
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Creates a new instance of the VercelProvider.
|
|
22
|
+
*
|
|
23
|
+
* This provider enables integration with the Vercel AI SDK,
|
|
24
|
+
* allowing Composio tools to be used with Vercel AI applications.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Initialize the Vercel provider
|
|
29
|
+
* const provider = new VercelProvider();
|
|
30
|
+
*
|
|
31
|
+
* // Use with Composio
|
|
32
|
+
* const composio = new Composio({
|
|
33
|
+
* apiKey: 'your-api-key',
|
|
34
|
+
* provider: new VercelProvider()
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Use the provider to wrap tools for Vercel AI SDK
|
|
38
|
+
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
constructor();
|
|
42
|
+
/**
|
|
43
|
+
* Wraps a Composio tool in a Vercel AI SDK tool format.
|
|
44
|
+
*
|
|
45
|
+
* This method transforms a Composio tool definition into the format
|
|
46
|
+
* expected by Vercel's AI SDK for function calling.
|
|
47
|
+
*
|
|
48
|
+
* @param {ComposioTool} composioTool - The Composio tool to wrap
|
|
49
|
+
* @param {ExecuteToolFn} executeTool - Function to execute the tool
|
|
50
|
+
* @returns {VercelTool} The wrapped Vercel tool
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // Wrap a single tool for use with Vercel AI SDK
|
|
55
|
+
* const composioTool = {
|
|
56
|
+
* slug: 'SEARCH_TOOL',
|
|
57
|
+
* description: 'Search for information',
|
|
58
|
+
* inputParameters: {
|
|
59
|
+
* type: 'object',
|
|
60
|
+
* properties: {
|
|
61
|
+
* query: { type: 'string' }
|
|
62
|
+
* },
|
|
63
|
+
* required: ['query']
|
|
64
|
+
* }
|
|
65
|
+
* };
|
|
66
|
+
*
|
|
67
|
+
* // Create a Vercel tool using the provider
|
|
68
|
+
* const vercelTool = provider.wrapTool(
|
|
69
|
+
* composioTool,
|
|
70
|
+
* composio.tools.execute
|
|
71
|
+
* );
|
|
72
|
+
*
|
|
73
|
+
* // Use with Vercel AI SDK
|
|
74
|
+
* import { StreamingTextResponse, Message } from 'ai';
|
|
75
|
+
* import { OpenAI } from 'openai';
|
|
76
|
+
*
|
|
77
|
+
* export async function POST(req: Request) {
|
|
78
|
+
* const { messages } = await req.json();
|
|
79
|
+
* const openai = new OpenAI();
|
|
80
|
+
*
|
|
81
|
+
* const response = await openai.chat.completions.create({
|
|
82
|
+
* model: 'gpt-4',
|
|
83
|
+
* messages,
|
|
84
|
+
* tools: [vercelTool]
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* return new StreamingTextResponse(response.choices[0].message);
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
24
90
|
*/
|
|
25
91
|
wrapTool(composioTool: Tool$1, executeTool: ExecuteToolFn): Tool;
|
|
26
92
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
93
|
+
* Wraps a list of Composio tools as a Vercel AI SDK tool collection.
|
|
94
|
+
*
|
|
95
|
+
* This method transforms multiple Composio tool definitions into the format
|
|
96
|
+
* expected by Vercel's AI SDK for function calling, organizing them
|
|
97
|
+
* into a dictionary keyed by tool slug.
|
|
98
|
+
*
|
|
99
|
+
* @param {ComposioTool[]} tools - Array of Composio tools to wrap
|
|
100
|
+
* @param {ExecuteToolFn} executeTool - Function to execute the tools
|
|
101
|
+
* @returns {VercelToolCollection} Dictionary of wrapped tools in Vercel AI SDK format
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // Wrap multiple tools for use with Vercel AI SDK
|
|
106
|
+
* const composioTools = [
|
|
107
|
+
* {
|
|
108
|
+
* slug: 'SEARCH_TOOL',
|
|
109
|
+
* description: 'Search for information',
|
|
110
|
+
* inputParameters: {
|
|
111
|
+
* type: 'object',
|
|
112
|
+
* properties: {
|
|
113
|
+
* query: { type: 'string' }
|
|
114
|
+
* },
|
|
115
|
+
* required: ['query']
|
|
116
|
+
* }
|
|
117
|
+
* },
|
|
118
|
+
* {
|
|
119
|
+
* slug: 'WEATHER_TOOL',
|
|
120
|
+
* description: 'Get weather information',
|
|
121
|
+
* inputParameters: {
|
|
122
|
+
* type: 'object',
|
|
123
|
+
* properties: {
|
|
124
|
+
* location: { type: 'string' }
|
|
125
|
+
* },
|
|
126
|
+
* required: ['location']
|
|
127
|
+
* }
|
|
128
|
+
* }
|
|
129
|
+
* ];
|
|
130
|
+
*
|
|
131
|
+
* // Create Vercel tools using the provider
|
|
132
|
+
* const vercelTools = provider.wrapTools(
|
|
133
|
+
* composioTools,
|
|
134
|
+
* composio.tools.execute
|
|
135
|
+
* );
|
|
136
|
+
*
|
|
137
|
+
* // Use with Vercel AI SDK in a Next.js API route
|
|
138
|
+
* import { StreamingTextResponse } from 'ai';
|
|
139
|
+
* import { OpenAI } from 'openai';
|
|
140
|
+
*
|
|
141
|
+
* export async function POST(req: Request) {
|
|
142
|
+
* const { messages } = await req.json();
|
|
143
|
+
* const openai = new OpenAI();
|
|
144
|
+
*
|
|
145
|
+
* const response = await openai.chat.completions.create({
|
|
146
|
+
* model: 'gpt-4',
|
|
147
|
+
* messages,
|
|
148
|
+
* tools: Object.values(vercelTools)
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* return new StreamingTextResponse(response.choices[0].message);
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
30
154
|
*/
|
|
31
155
|
wrapTools(tools: Tool$1[], executeTool: ExecuteToolFn): VercelToolCollection;
|
|
32
156
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,77 @@ import { jsonSchema, tool } from "ai";
|
|
|
4
4
|
var VercelProvider = class extends BaseAgenticProvider {
|
|
5
5
|
name = "vercel";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Creates a new instance of the VercelProvider.
|
|
8
|
+
*
|
|
9
|
+
* This provider enables integration with the Vercel AI SDK,
|
|
10
|
+
* allowing Composio tools to be used with Vercel AI applications.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Initialize the Vercel provider
|
|
15
|
+
* const provider = new VercelProvider();
|
|
16
|
+
*
|
|
17
|
+
* // Use with Composio
|
|
18
|
+
* const composio = new Composio({
|
|
19
|
+
* apiKey: 'your-api-key',
|
|
20
|
+
* provider: new VercelProvider()
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Use the provider to wrap tools for Vercel AI SDK
|
|
24
|
+
* const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Wraps a Composio tool in a Vercel AI SDK tool format.
|
|
32
|
+
*
|
|
33
|
+
* This method transforms a Composio tool definition into the format
|
|
34
|
+
* expected by Vercel's AI SDK for function calling.
|
|
35
|
+
*
|
|
36
|
+
* @param {ComposioTool} composioTool - The Composio tool to wrap
|
|
37
|
+
* @param {ExecuteToolFn} executeTool - Function to execute the tool
|
|
38
|
+
* @returns {VercelTool} The wrapped Vercel tool
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Wrap a single tool for use with Vercel AI SDK
|
|
43
|
+
* const composioTool = {
|
|
44
|
+
* slug: 'SEARCH_TOOL',
|
|
45
|
+
* description: 'Search for information',
|
|
46
|
+
* inputParameters: {
|
|
47
|
+
* type: 'object',
|
|
48
|
+
* properties: {
|
|
49
|
+
* query: { type: 'string' }
|
|
50
|
+
* },
|
|
51
|
+
* required: ['query']
|
|
52
|
+
* }
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* // Create a Vercel tool using the provider
|
|
56
|
+
* const vercelTool = provider.wrapTool(
|
|
57
|
+
* composioTool,
|
|
58
|
+
* composio.tools.execute
|
|
59
|
+
* );
|
|
60
|
+
*
|
|
61
|
+
* // Use with Vercel AI SDK
|
|
62
|
+
* import { StreamingTextResponse, Message } from 'ai';
|
|
63
|
+
* import { OpenAI } from 'openai';
|
|
64
|
+
*
|
|
65
|
+
* export async function POST(req: Request) {
|
|
66
|
+
* const { messages } = await req.json();
|
|
67
|
+
* const openai = new OpenAI();
|
|
68
|
+
*
|
|
69
|
+
* const response = await openai.chat.completions.create({
|
|
70
|
+
* model: 'gpt-4',
|
|
71
|
+
* messages,
|
|
72
|
+
* tools: [vercelTool]
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* return new StreamingTextResponse(response.choices[0].message);
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
10
78
|
*/
|
|
11
79
|
wrapTool(composioTool, executeTool) {
|
|
12
80
|
return tool({
|
|
@@ -19,9 +87,67 @@ var VercelProvider = class extends BaseAgenticProvider {
|
|
|
19
87
|
});
|
|
20
88
|
}
|
|
21
89
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
90
|
+
* Wraps a list of Composio tools as a Vercel AI SDK tool collection.
|
|
91
|
+
*
|
|
92
|
+
* This method transforms multiple Composio tool definitions into the format
|
|
93
|
+
* expected by Vercel's AI SDK for function calling, organizing them
|
|
94
|
+
* into a dictionary keyed by tool slug.
|
|
95
|
+
*
|
|
96
|
+
* @param {ComposioTool[]} tools - Array of Composio tools to wrap
|
|
97
|
+
* @param {ExecuteToolFn} executeTool - Function to execute the tools
|
|
98
|
+
* @returns {VercelToolCollection} Dictionary of wrapped tools in Vercel AI SDK format
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* // Wrap multiple tools for use with Vercel AI SDK
|
|
103
|
+
* const composioTools = [
|
|
104
|
+
* {
|
|
105
|
+
* slug: 'SEARCH_TOOL',
|
|
106
|
+
* description: 'Search for information',
|
|
107
|
+
* inputParameters: {
|
|
108
|
+
* type: 'object',
|
|
109
|
+
* properties: {
|
|
110
|
+
* query: { type: 'string' }
|
|
111
|
+
* },
|
|
112
|
+
* required: ['query']
|
|
113
|
+
* }
|
|
114
|
+
* },
|
|
115
|
+
* {
|
|
116
|
+
* slug: 'WEATHER_TOOL',
|
|
117
|
+
* description: 'Get weather information',
|
|
118
|
+
* inputParameters: {
|
|
119
|
+
* type: 'object',
|
|
120
|
+
* properties: {
|
|
121
|
+
* location: { type: 'string' }
|
|
122
|
+
* },
|
|
123
|
+
* required: ['location']
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
126
|
+
* ];
|
|
127
|
+
*
|
|
128
|
+
* // Create Vercel tools using the provider
|
|
129
|
+
* const vercelTools = provider.wrapTools(
|
|
130
|
+
* composioTools,
|
|
131
|
+
* composio.tools.execute
|
|
132
|
+
* );
|
|
133
|
+
*
|
|
134
|
+
* // Use with Vercel AI SDK in a Next.js API route
|
|
135
|
+
* import { StreamingTextResponse } from 'ai';
|
|
136
|
+
* import { OpenAI } from 'openai';
|
|
137
|
+
*
|
|
138
|
+
* export async function POST(req: Request) {
|
|
139
|
+
* const { messages } = await req.json();
|
|
140
|
+
* const openai = new OpenAI();
|
|
141
|
+
*
|
|
142
|
+
* const response = await openai.chat.completions.create({
|
|
143
|
+
* model: 'gpt-4',
|
|
144
|
+
* messages,
|
|
145
|
+
* tools: Object.values(vercelTools)
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* return new StreamingTextResponse(response.choices[0].message);
|
|
149
|
+
* }
|
|
150
|
+
* ```
|
|
25
151
|
*/
|
|
26
152
|
wrapTools(tools, executeTool) {
|
|
27
153
|
return tools.reduce((acc, tool2) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/vercel",
|
|
3
|
-
"version": "0.1.12-alpha.
|
|
3
|
+
"version": "0.1.12-alpha.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "ISC",
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@composio/core": "0.1.12-alpha.
|
|
25
|
+
"@composio/core": "0.1.12-alpha.16",
|
|
26
26
|
"ai": "^4.3.8"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"tsup": "^8.4.0",
|
|
30
30
|
"typescript": "^5.8.3",
|
|
31
31
|
"vitest": "^3.1.4",
|
|
32
|
-
"@composio/core": "0.1.12-alpha.
|
|
32
|
+
"@composio/core": "0.1.12-alpha.16"
|
|
33
33
|
},
|
|
34
34
|
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
|
|
35
35
|
"scripts": {
|