@composio/google 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 +146 -12
- package/dist/index.d.cts +144 -12
- package/dist/index.d.ts +144 -12
- package/dist/index.js +146 -12
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -27,9 +27,63 @@ var import_core = require("@composio/core");
|
|
|
27
27
|
var GoogleProvider = class extends import_core.BaseNonAgenticProvider {
|
|
28
28
|
name = "google";
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
* Creates a new instance of the GoogleProvider.
|
|
31
|
+
*
|
|
32
|
+
* This provider enables integration with Google's GenAI API,
|
|
33
|
+
* supporting both the Gemini Developer API and Vertex AI implementations.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* // Initialize the Google provider
|
|
38
|
+
* const provider = new GoogleProvider();
|
|
39
|
+
*
|
|
40
|
+
* // Use with Composio
|
|
41
|
+
* const composio = new Composio({
|
|
42
|
+
* apiKey: 'your-api-key',
|
|
43
|
+
* provider: new GoogleProvider()
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Use the provider to wrap tools for Google GenAI
|
|
47
|
+
* const googleTools = provider.wrapTools(composioTools);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
constructor() {
|
|
51
|
+
super();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Wraps a Composio tool in the Google GenAI function declaration format.
|
|
55
|
+
*
|
|
56
|
+
* This method transforms a Composio tool definition into the format
|
|
57
|
+
* expected by Google's GenAI API for function calling.
|
|
58
|
+
*
|
|
59
|
+
* @param tool - The Composio tool to wrap
|
|
60
|
+
* @returns The wrapped tool in Google GenAI format
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // Wrap a single tool for use with Google GenAI
|
|
65
|
+
* const composioTool = {
|
|
66
|
+
* slug: 'SEARCH_TOOL',
|
|
67
|
+
* description: 'Search for information',
|
|
68
|
+
* inputParameters: {
|
|
69
|
+
* type: 'object',
|
|
70
|
+
* properties: {
|
|
71
|
+
* query: { type: 'string' }
|
|
72
|
+
* },
|
|
73
|
+
* required: ['query']
|
|
74
|
+
* }
|
|
75
|
+
* };
|
|
76
|
+
*
|
|
77
|
+
* const googleTool = provider.wrapTool(composioTool);
|
|
78
|
+
* // Use with Google GenAI SDK
|
|
79
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
80
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
81
|
+
*
|
|
82
|
+
* const result = await model.generateContent({
|
|
83
|
+
* contents: [{ role: 'user', parts: [{ text: 'Search for Composio' }] }],
|
|
84
|
+
* tools: [googleTool]
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
33
87
|
*/
|
|
34
88
|
wrapTool(tool) {
|
|
35
89
|
return {
|
|
@@ -44,20 +98,100 @@ var GoogleProvider = class extends import_core.BaseNonAgenticProvider {
|
|
|
44
98
|
};
|
|
45
99
|
}
|
|
46
100
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
101
|
+
* Wraps a list of Composio tools in the Google GenAI function declaration format.
|
|
102
|
+
*
|
|
103
|
+
* This method transforms multiple Composio tool definitions into the format
|
|
104
|
+
* expected by Google's GenAI API for function calling.
|
|
105
|
+
*
|
|
106
|
+
* @param tools - Array of Composio tools to wrap
|
|
107
|
+
* @returns Array of wrapped tools in Google GenAI format
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // Wrap multiple tools for use with Google GenAI
|
|
112
|
+
* const composioTools = [
|
|
113
|
+
* {
|
|
114
|
+
* slug: 'SEARCH_TOOL',
|
|
115
|
+
* description: 'Search for information',
|
|
116
|
+
* inputParameters: {
|
|
117
|
+
* type: 'object',
|
|
118
|
+
* properties: {
|
|
119
|
+
* query: { type: 'string' }
|
|
120
|
+
* },
|
|
121
|
+
* required: ['query']
|
|
122
|
+
* }
|
|
123
|
+
* },
|
|
124
|
+
* {
|
|
125
|
+
* slug: 'WEATHER_TOOL',
|
|
126
|
+
* description: 'Get weather information',
|
|
127
|
+
* inputParameters: {
|
|
128
|
+
* type: 'object',
|
|
129
|
+
* properties: {
|
|
130
|
+
* location: { type: 'string' }
|
|
131
|
+
* },
|
|
132
|
+
* required: ['location']
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* ];
|
|
136
|
+
*
|
|
137
|
+
* const googleTools = provider.wrapTools(composioTools);
|
|
138
|
+
*
|
|
139
|
+
* // Use with Google GenAI SDK
|
|
140
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
141
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
142
|
+
*
|
|
143
|
+
* const result = await model.generateContent({
|
|
144
|
+
* contents: [{ role: 'user', parts: [{ text: 'How is the weather in New York?' }] }],
|
|
145
|
+
* tools: googleTools
|
|
146
|
+
* });
|
|
147
|
+
* ```
|
|
50
148
|
*/
|
|
51
149
|
wrapTools(tools) {
|
|
52
150
|
return tools.map((tool) => this.wrapTool(tool));
|
|
53
151
|
}
|
|
54
152
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
153
|
+
* Executes a tool call from Google GenAI.
|
|
154
|
+
*
|
|
155
|
+
* This method processes a function call from Google's GenAI API,
|
|
156
|
+
* executes the corresponding Composio tool, and returns the result.
|
|
157
|
+
*
|
|
158
|
+
* @param userId - The user ID for authentication and tracking
|
|
159
|
+
* @param tool - The Google GenAI function call to execute
|
|
160
|
+
* @param options - Optional execution options like connected account ID
|
|
161
|
+
* @param modifiers - Optional execution modifiers for tool behavior
|
|
162
|
+
* @returns The result of the tool execution as a JSON string
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* // Execute a tool call from Google GenAI
|
|
167
|
+
* const functionCall = {
|
|
168
|
+
* name: 'SEARCH_TOOL',
|
|
169
|
+
* args: {
|
|
170
|
+
* query: 'composio documentation'
|
|
171
|
+
* }
|
|
172
|
+
* };
|
|
173
|
+
*
|
|
174
|
+
* const result = await provider.executeToolCall(
|
|
175
|
+
* 'user123',
|
|
176
|
+
* functionCall,
|
|
177
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
178
|
+
* );
|
|
179
|
+
*
|
|
180
|
+
* // Parse the result and use it in your application
|
|
181
|
+
* const searchResults = JSON.parse(result);
|
|
182
|
+
* console.log(searchResults);
|
|
183
|
+
*
|
|
184
|
+
* // You can also use the result to continue the conversation
|
|
185
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
186
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
187
|
+
*
|
|
188
|
+
* await model.generateContent({
|
|
189
|
+
* contents: [
|
|
190
|
+
* { role: 'user', parts: [{ text: 'Search for Composio' }] },
|
|
191
|
+
* { role: 'model', parts: [{ functionResponse: { name: 'SEARCH_TOOL', response: result } }] }
|
|
192
|
+
* ]
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
61
195
|
*/
|
|
62
196
|
async executeToolCall(userId, tool, options, modifiers) {
|
|
63
197
|
const payload = {
|
package/dist/index.d.cts
CHANGED
|
@@ -35,24 +35,156 @@ type GoogleGenAIToolCollection = GoogleTool[];
|
|
|
35
35
|
declare class GoogleProvider extends BaseNonAgenticProvider<GoogleGenAIToolCollection, GoogleTool> {
|
|
36
36
|
readonly name = "google";
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* Creates a new instance of the GoogleProvider.
|
|
39
|
+
*
|
|
40
|
+
* This provider enables integration with Google's GenAI API,
|
|
41
|
+
* supporting both the Gemini Developer API and Vertex AI implementations.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Initialize the Google provider
|
|
46
|
+
* const provider = new GoogleProvider();
|
|
47
|
+
*
|
|
48
|
+
* // Use with Composio
|
|
49
|
+
* const composio = new Composio({
|
|
50
|
+
* apiKey: 'your-api-key',
|
|
51
|
+
* provider: new GoogleProvider()
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Use the provider to wrap tools for Google GenAI
|
|
55
|
+
* const googleTools = provider.wrapTools(composioTools);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
constructor();
|
|
59
|
+
/**
|
|
60
|
+
* Wraps a Composio tool in the Google GenAI function declaration format.
|
|
61
|
+
*
|
|
62
|
+
* This method transforms a Composio tool definition into the format
|
|
63
|
+
* expected by Google's GenAI API for function calling.
|
|
64
|
+
*
|
|
65
|
+
* @param tool - The Composio tool to wrap
|
|
66
|
+
* @returns The wrapped tool in Google GenAI format
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Wrap a single tool for use with Google GenAI
|
|
71
|
+
* const composioTool = {
|
|
72
|
+
* slug: 'SEARCH_TOOL',
|
|
73
|
+
* description: 'Search for information',
|
|
74
|
+
* inputParameters: {
|
|
75
|
+
* type: 'object',
|
|
76
|
+
* properties: {
|
|
77
|
+
* query: { type: 'string' }
|
|
78
|
+
* },
|
|
79
|
+
* required: ['query']
|
|
80
|
+
* }
|
|
81
|
+
* };
|
|
82
|
+
*
|
|
83
|
+
* const googleTool = provider.wrapTool(composioTool);
|
|
84
|
+
* // Use with Google GenAI SDK
|
|
85
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
86
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
87
|
+
*
|
|
88
|
+
* const result = await model.generateContent({
|
|
89
|
+
* contents: [{ role: 'user', parts: [{ text: 'Search for Composio' }] }],
|
|
90
|
+
* tools: [googleTool]
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
41
93
|
*/
|
|
42
94
|
wrapTool(tool: Tool): GoogleTool;
|
|
43
95
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
96
|
+
* Wraps a list of Composio tools in the Google GenAI function declaration format.
|
|
97
|
+
*
|
|
98
|
+
* This method transforms multiple Composio tool definitions into the format
|
|
99
|
+
* expected by Google's GenAI API for function calling.
|
|
100
|
+
*
|
|
101
|
+
* @param tools - Array of Composio tools to wrap
|
|
102
|
+
* @returns Array of wrapped tools in Google GenAI format
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* // Wrap multiple tools for use with Google GenAI
|
|
107
|
+
* const composioTools = [
|
|
108
|
+
* {
|
|
109
|
+
* slug: 'SEARCH_TOOL',
|
|
110
|
+
* description: 'Search for information',
|
|
111
|
+
* inputParameters: {
|
|
112
|
+
* type: 'object',
|
|
113
|
+
* properties: {
|
|
114
|
+
* query: { type: 'string' }
|
|
115
|
+
* },
|
|
116
|
+
* required: ['query']
|
|
117
|
+
* }
|
|
118
|
+
* },
|
|
119
|
+
* {
|
|
120
|
+
* slug: 'WEATHER_TOOL',
|
|
121
|
+
* description: 'Get weather information',
|
|
122
|
+
* inputParameters: {
|
|
123
|
+
* type: 'object',
|
|
124
|
+
* properties: {
|
|
125
|
+
* location: { type: 'string' }
|
|
126
|
+
* },
|
|
127
|
+
* required: ['location']
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
* ];
|
|
131
|
+
*
|
|
132
|
+
* const googleTools = provider.wrapTools(composioTools);
|
|
133
|
+
*
|
|
134
|
+
* // Use with Google GenAI SDK
|
|
135
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
136
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
137
|
+
*
|
|
138
|
+
* const result = await model.generateContent({
|
|
139
|
+
* contents: [{ role: 'user', parts: [{ text: 'How is the weather in New York?' }] }],
|
|
140
|
+
* tools: googleTools
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
47
143
|
*/
|
|
48
144
|
wrapTools(tools: Tool[]): GoogleGenAIToolCollection;
|
|
49
145
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
146
|
+
* Executes a tool call from Google GenAI.
|
|
147
|
+
*
|
|
148
|
+
* This method processes a function call from Google's GenAI API,
|
|
149
|
+
* executes the corresponding Composio tool, and returns the result.
|
|
150
|
+
*
|
|
151
|
+
* @param userId - The user ID for authentication and tracking
|
|
152
|
+
* @param tool - The Google GenAI function call to execute
|
|
153
|
+
* @param options - Optional execution options like connected account ID
|
|
154
|
+
* @param modifiers - Optional execution modifiers for tool behavior
|
|
155
|
+
* @returns The result of the tool execution as a JSON string
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* // Execute a tool call from Google GenAI
|
|
160
|
+
* const functionCall = {
|
|
161
|
+
* name: 'SEARCH_TOOL',
|
|
162
|
+
* args: {
|
|
163
|
+
* query: 'composio documentation'
|
|
164
|
+
* }
|
|
165
|
+
* };
|
|
166
|
+
*
|
|
167
|
+
* const result = await provider.executeToolCall(
|
|
168
|
+
* 'user123',
|
|
169
|
+
* functionCall,
|
|
170
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
171
|
+
* );
|
|
172
|
+
*
|
|
173
|
+
* // Parse the result and use it in your application
|
|
174
|
+
* const searchResults = JSON.parse(result);
|
|
175
|
+
* console.log(searchResults);
|
|
176
|
+
*
|
|
177
|
+
* // You can also use the result to continue the conversation
|
|
178
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
179
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
180
|
+
*
|
|
181
|
+
* await model.generateContent({
|
|
182
|
+
* contents: [
|
|
183
|
+
* { role: 'user', parts: [{ text: 'Search for Composio' }] },
|
|
184
|
+
* { role: 'model', parts: [{ functionResponse: { name: 'SEARCH_TOOL', response: result } }] }
|
|
185
|
+
* ]
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
56
188
|
*/
|
|
57
189
|
executeToolCall(userId: string, tool: GoogleGenAIFunctionCall, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string>;
|
|
58
190
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,24 +35,156 @@ type GoogleGenAIToolCollection = GoogleTool[];
|
|
|
35
35
|
declare class GoogleProvider extends BaseNonAgenticProvider<GoogleGenAIToolCollection, GoogleTool> {
|
|
36
36
|
readonly name = "google";
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* Creates a new instance of the GoogleProvider.
|
|
39
|
+
*
|
|
40
|
+
* This provider enables integration with Google's GenAI API,
|
|
41
|
+
* supporting both the Gemini Developer API and Vertex AI implementations.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Initialize the Google provider
|
|
46
|
+
* const provider = new GoogleProvider();
|
|
47
|
+
*
|
|
48
|
+
* // Use with Composio
|
|
49
|
+
* const composio = new Composio({
|
|
50
|
+
* apiKey: 'your-api-key',
|
|
51
|
+
* provider: new GoogleProvider()
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Use the provider to wrap tools for Google GenAI
|
|
55
|
+
* const googleTools = provider.wrapTools(composioTools);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
constructor();
|
|
59
|
+
/**
|
|
60
|
+
* Wraps a Composio tool in the Google GenAI function declaration format.
|
|
61
|
+
*
|
|
62
|
+
* This method transforms a Composio tool definition into the format
|
|
63
|
+
* expected by Google's GenAI API for function calling.
|
|
64
|
+
*
|
|
65
|
+
* @param tool - The Composio tool to wrap
|
|
66
|
+
* @returns The wrapped tool in Google GenAI format
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Wrap a single tool for use with Google GenAI
|
|
71
|
+
* const composioTool = {
|
|
72
|
+
* slug: 'SEARCH_TOOL',
|
|
73
|
+
* description: 'Search for information',
|
|
74
|
+
* inputParameters: {
|
|
75
|
+
* type: 'object',
|
|
76
|
+
* properties: {
|
|
77
|
+
* query: { type: 'string' }
|
|
78
|
+
* },
|
|
79
|
+
* required: ['query']
|
|
80
|
+
* }
|
|
81
|
+
* };
|
|
82
|
+
*
|
|
83
|
+
* const googleTool = provider.wrapTool(composioTool);
|
|
84
|
+
* // Use with Google GenAI SDK
|
|
85
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
86
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
87
|
+
*
|
|
88
|
+
* const result = await model.generateContent({
|
|
89
|
+
* contents: [{ role: 'user', parts: [{ text: 'Search for Composio' }] }],
|
|
90
|
+
* tools: [googleTool]
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
41
93
|
*/
|
|
42
94
|
wrapTool(tool: Tool): GoogleTool;
|
|
43
95
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
96
|
+
* Wraps a list of Composio tools in the Google GenAI function declaration format.
|
|
97
|
+
*
|
|
98
|
+
* This method transforms multiple Composio tool definitions into the format
|
|
99
|
+
* expected by Google's GenAI API for function calling.
|
|
100
|
+
*
|
|
101
|
+
* @param tools - Array of Composio tools to wrap
|
|
102
|
+
* @returns Array of wrapped tools in Google GenAI format
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* // Wrap multiple tools for use with Google GenAI
|
|
107
|
+
* const composioTools = [
|
|
108
|
+
* {
|
|
109
|
+
* slug: 'SEARCH_TOOL',
|
|
110
|
+
* description: 'Search for information',
|
|
111
|
+
* inputParameters: {
|
|
112
|
+
* type: 'object',
|
|
113
|
+
* properties: {
|
|
114
|
+
* query: { type: 'string' }
|
|
115
|
+
* },
|
|
116
|
+
* required: ['query']
|
|
117
|
+
* }
|
|
118
|
+
* },
|
|
119
|
+
* {
|
|
120
|
+
* slug: 'WEATHER_TOOL',
|
|
121
|
+
* description: 'Get weather information',
|
|
122
|
+
* inputParameters: {
|
|
123
|
+
* type: 'object',
|
|
124
|
+
* properties: {
|
|
125
|
+
* location: { type: 'string' }
|
|
126
|
+
* },
|
|
127
|
+
* required: ['location']
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
* ];
|
|
131
|
+
*
|
|
132
|
+
* const googleTools = provider.wrapTools(composioTools);
|
|
133
|
+
*
|
|
134
|
+
* // Use with Google GenAI SDK
|
|
135
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
136
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
137
|
+
*
|
|
138
|
+
* const result = await model.generateContent({
|
|
139
|
+
* contents: [{ role: 'user', parts: [{ text: 'How is the weather in New York?' }] }],
|
|
140
|
+
* tools: googleTools
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
47
143
|
*/
|
|
48
144
|
wrapTools(tools: Tool[]): GoogleGenAIToolCollection;
|
|
49
145
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
146
|
+
* Executes a tool call from Google GenAI.
|
|
147
|
+
*
|
|
148
|
+
* This method processes a function call from Google's GenAI API,
|
|
149
|
+
* executes the corresponding Composio tool, and returns the result.
|
|
150
|
+
*
|
|
151
|
+
* @param userId - The user ID for authentication and tracking
|
|
152
|
+
* @param tool - The Google GenAI function call to execute
|
|
153
|
+
* @param options - Optional execution options like connected account ID
|
|
154
|
+
* @param modifiers - Optional execution modifiers for tool behavior
|
|
155
|
+
* @returns The result of the tool execution as a JSON string
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* // Execute a tool call from Google GenAI
|
|
160
|
+
* const functionCall = {
|
|
161
|
+
* name: 'SEARCH_TOOL',
|
|
162
|
+
* args: {
|
|
163
|
+
* query: 'composio documentation'
|
|
164
|
+
* }
|
|
165
|
+
* };
|
|
166
|
+
*
|
|
167
|
+
* const result = await provider.executeToolCall(
|
|
168
|
+
* 'user123',
|
|
169
|
+
* functionCall,
|
|
170
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
171
|
+
* );
|
|
172
|
+
*
|
|
173
|
+
* // Parse the result and use it in your application
|
|
174
|
+
* const searchResults = JSON.parse(result);
|
|
175
|
+
* console.log(searchResults);
|
|
176
|
+
*
|
|
177
|
+
* // You can also use the result to continue the conversation
|
|
178
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
179
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
180
|
+
*
|
|
181
|
+
* await model.generateContent({
|
|
182
|
+
* contents: [
|
|
183
|
+
* { role: 'user', parts: [{ text: 'Search for Composio' }] },
|
|
184
|
+
* { role: 'model', parts: [{ functionResponse: { name: 'SEARCH_TOOL', response: result } }] }
|
|
185
|
+
* ]
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
56
188
|
*/
|
|
57
189
|
executeToolCall(userId: string, tool: GoogleGenAIFunctionCall, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string>;
|
|
58
190
|
}
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,63 @@ import {
|
|
|
5
5
|
var GoogleProvider = class extends BaseNonAgenticProvider {
|
|
6
6
|
name = "google";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Creates a new instance of the GoogleProvider.
|
|
9
|
+
*
|
|
10
|
+
* This provider enables integration with Google's GenAI API,
|
|
11
|
+
* supporting both the Gemini Developer API and Vertex AI implementations.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Initialize the Google provider
|
|
16
|
+
* const provider = new GoogleProvider();
|
|
17
|
+
*
|
|
18
|
+
* // Use with Composio
|
|
19
|
+
* const composio = new Composio({
|
|
20
|
+
* apiKey: 'your-api-key',
|
|
21
|
+
* provider: new GoogleProvider()
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Use the provider to wrap tools for Google GenAI
|
|
25
|
+
* const googleTools = provider.wrapTools(composioTools);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Wraps a Composio tool in the Google GenAI function declaration format.
|
|
33
|
+
*
|
|
34
|
+
* This method transforms a Composio tool definition into the format
|
|
35
|
+
* expected by Google's GenAI API for function calling.
|
|
36
|
+
*
|
|
37
|
+
* @param tool - The Composio tool to wrap
|
|
38
|
+
* @returns The wrapped tool in Google GenAI format
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Wrap a single tool for use with Google GenAI
|
|
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
|
+
* const googleTool = provider.wrapTool(composioTool);
|
|
56
|
+
* // Use with Google GenAI SDK
|
|
57
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
58
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
59
|
+
*
|
|
60
|
+
* const result = await model.generateContent({
|
|
61
|
+
* contents: [{ role: 'user', parts: [{ text: 'Search for Composio' }] }],
|
|
62
|
+
* tools: [googleTool]
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
11
65
|
*/
|
|
12
66
|
wrapTool(tool) {
|
|
13
67
|
return {
|
|
@@ -22,20 +76,100 @@ var GoogleProvider = class extends BaseNonAgenticProvider {
|
|
|
22
76
|
};
|
|
23
77
|
}
|
|
24
78
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
79
|
+
* Wraps a list of Composio tools in the Google GenAI function declaration format.
|
|
80
|
+
*
|
|
81
|
+
* This method transforms multiple Composio tool definitions into the format
|
|
82
|
+
* expected by Google's GenAI API for function calling.
|
|
83
|
+
*
|
|
84
|
+
* @param tools - Array of Composio tools to wrap
|
|
85
|
+
* @returns Array of wrapped tools in Google GenAI format
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // Wrap multiple tools for use with Google GenAI
|
|
90
|
+
* const composioTools = [
|
|
91
|
+
* {
|
|
92
|
+
* slug: 'SEARCH_TOOL',
|
|
93
|
+
* description: 'Search for information',
|
|
94
|
+
* inputParameters: {
|
|
95
|
+
* type: 'object',
|
|
96
|
+
* properties: {
|
|
97
|
+
* query: { type: 'string' }
|
|
98
|
+
* },
|
|
99
|
+
* required: ['query']
|
|
100
|
+
* }
|
|
101
|
+
* },
|
|
102
|
+
* {
|
|
103
|
+
* slug: 'WEATHER_TOOL',
|
|
104
|
+
* description: 'Get weather information',
|
|
105
|
+
* inputParameters: {
|
|
106
|
+
* type: 'object',
|
|
107
|
+
* properties: {
|
|
108
|
+
* location: { type: 'string' }
|
|
109
|
+
* },
|
|
110
|
+
* required: ['location']
|
|
111
|
+
* }
|
|
112
|
+
* }
|
|
113
|
+
* ];
|
|
114
|
+
*
|
|
115
|
+
* const googleTools = provider.wrapTools(composioTools);
|
|
116
|
+
*
|
|
117
|
+
* // Use with Google GenAI SDK
|
|
118
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
119
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
120
|
+
*
|
|
121
|
+
* const result = await model.generateContent({
|
|
122
|
+
* contents: [{ role: 'user', parts: [{ text: 'How is the weather in New York?' }] }],
|
|
123
|
+
* tools: googleTools
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
28
126
|
*/
|
|
29
127
|
wrapTools(tools) {
|
|
30
128
|
return tools.map((tool) => this.wrapTool(tool));
|
|
31
129
|
}
|
|
32
130
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
131
|
+
* Executes a tool call from Google GenAI.
|
|
132
|
+
*
|
|
133
|
+
* This method processes a function call from Google's GenAI API,
|
|
134
|
+
* executes the corresponding Composio tool, and returns the result.
|
|
135
|
+
*
|
|
136
|
+
* @param userId - The user ID for authentication and tracking
|
|
137
|
+
* @param tool - The Google GenAI function call to execute
|
|
138
|
+
* @param options - Optional execution options like connected account ID
|
|
139
|
+
* @param modifiers - Optional execution modifiers for tool behavior
|
|
140
|
+
* @returns The result of the tool execution as a JSON string
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* // Execute a tool call from Google GenAI
|
|
145
|
+
* const functionCall = {
|
|
146
|
+
* name: 'SEARCH_TOOL',
|
|
147
|
+
* args: {
|
|
148
|
+
* query: 'composio documentation'
|
|
149
|
+
* }
|
|
150
|
+
* };
|
|
151
|
+
*
|
|
152
|
+
* const result = await provider.executeToolCall(
|
|
153
|
+
* 'user123',
|
|
154
|
+
* functionCall,
|
|
155
|
+
* { connectedAccountId: 'conn_xyz456' }
|
|
156
|
+
* );
|
|
157
|
+
*
|
|
158
|
+
* // Parse the result and use it in your application
|
|
159
|
+
* const searchResults = JSON.parse(result);
|
|
160
|
+
* console.log(searchResults);
|
|
161
|
+
*
|
|
162
|
+
* // You can also use the result to continue the conversation
|
|
163
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
164
|
+
* const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
|
|
165
|
+
*
|
|
166
|
+
* await model.generateContent({
|
|
167
|
+
* contents: [
|
|
168
|
+
* { role: 'user', parts: [{ text: 'Search for Composio' }] },
|
|
169
|
+
* { role: 'model', parts: [{ functionResponse: { name: 'SEARCH_TOOL', response: result } }] }
|
|
170
|
+
* ]
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
39
173
|
*/
|
|
40
174
|
async executeToolCall(userId, tool, options, modifiers) {
|
|
41
175
|
const payload = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/google",
|
|
3
|
-
"version": "0.1.12-alpha.
|
|
3
|
+
"version": "0.1.12-alpha.16",
|
|
4
4
|
"description": "Google GenAI Provider for Composio SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"author": "",
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@composio/core": "0.1.12-alpha.
|
|
31
|
+
"@composio/core": "0.1.12-alpha.16",
|
|
32
32
|
"@google/genai": "^1.1.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"tsup": "^8.4.0",
|
|
36
36
|
"typescript": "^5.8.3",
|
|
37
|
-
"@composio/core": "0.1.12-alpha.
|
|
37
|
+
"@composio/core": "0.1.12-alpha.16"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsup",
|