@ai-sdk/google 3.0.43 → 3.0.44
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/CHANGELOG.md +6 -0
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +16 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +16 -4
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/google-prepare-tools.ts +19 -5
|
@@ -31,7 +31,7 @@ export function prepareTools({
|
|
|
31
31
|
| undefined
|
|
32
32
|
| {
|
|
33
33
|
functionCallingConfig: {
|
|
34
|
-
mode: 'AUTO' | 'NONE' | 'ANY';
|
|
34
|
+
mode: 'AUTO' | 'NONE' | 'ANY' | 'VALIDATED';
|
|
35
35
|
allowedFunctionNames?: string[];
|
|
36
36
|
};
|
|
37
37
|
};
|
|
@@ -186,6 +186,7 @@ export function prepareTools({
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
const functionDeclarations = [];
|
|
189
|
+
let hasStrictTools = false;
|
|
189
190
|
for (const tool of tools) {
|
|
190
191
|
switch (tool.type) {
|
|
191
192
|
case 'function':
|
|
@@ -194,6 +195,9 @@ export function prepareTools({
|
|
|
194
195
|
description: tool.description ?? '',
|
|
195
196
|
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema),
|
|
196
197
|
});
|
|
198
|
+
if (tool.strict === true) {
|
|
199
|
+
hasStrictTools = true;
|
|
200
|
+
}
|
|
197
201
|
break;
|
|
198
202
|
default:
|
|
199
203
|
toolWarnings.push({
|
|
@@ -207,7 +211,9 @@ export function prepareTools({
|
|
|
207
211
|
if (toolChoice == null) {
|
|
208
212
|
return {
|
|
209
213
|
tools: [{ functionDeclarations }],
|
|
210
|
-
toolConfig:
|
|
214
|
+
toolConfig: hasStrictTools
|
|
215
|
+
? { functionCallingConfig: { mode: 'VALIDATED' } }
|
|
216
|
+
: undefined,
|
|
211
217
|
toolWarnings,
|
|
212
218
|
};
|
|
213
219
|
}
|
|
@@ -218,7 +224,11 @@ export function prepareTools({
|
|
|
218
224
|
case 'auto':
|
|
219
225
|
return {
|
|
220
226
|
tools: [{ functionDeclarations }],
|
|
221
|
-
toolConfig: {
|
|
227
|
+
toolConfig: {
|
|
228
|
+
functionCallingConfig: {
|
|
229
|
+
mode: hasStrictTools ? 'VALIDATED' : 'AUTO',
|
|
230
|
+
},
|
|
231
|
+
},
|
|
222
232
|
toolWarnings,
|
|
223
233
|
};
|
|
224
234
|
case 'none':
|
|
@@ -230,7 +240,11 @@ export function prepareTools({
|
|
|
230
240
|
case 'required':
|
|
231
241
|
return {
|
|
232
242
|
tools: [{ functionDeclarations }],
|
|
233
|
-
toolConfig: {
|
|
243
|
+
toolConfig: {
|
|
244
|
+
functionCallingConfig: {
|
|
245
|
+
mode: hasStrictTools ? 'VALIDATED' : 'ANY',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
234
248
|
toolWarnings,
|
|
235
249
|
};
|
|
236
250
|
case 'tool':
|
|
@@ -238,7 +252,7 @@ export function prepareTools({
|
|
|
238
252
|
tools: [{ functionDeclarations }],
|
|
239
253
|
toolConfig: {
|
|
240
254
|
functionCallingConfig: {
|
|
241
|
-
mode: 'ANY',
|
|
255
|
+
mode: hasStrictTools ? 'VALIDATED' : 'ANY',
|
|
242
256
|
allowedFunctionNames: [toolChoice.toolName],
|
|
243
257
|
},
|
|
244
258
|
},
|