@ai-sdk/google 3.0.100 → 3.0.102
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 +12 -0
- package/dist/index.js +50 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -26
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +49 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +49 -25
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/convert-to-google-generative-ai-messages.ts +16 -4
- package/src/google-generative-ai-language-model.ts +1 -0
- package/src/interactions/google-interactions-language-model.ts +21 -0
- package/src/interactions/google-interactions-prompt.ts +1 -0
package/dist/internal/index.mjs
CHANGED
|
@@ -212,7 +212,7 @@ function convertUrlToolResultPart(url) {
|
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
215
|
+
function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
|
|
216
216
|
const functionResponseParts = [];
|
|
217
217
|
const responseTextParts = [];
|
|
218
218
|
for (const contentPart of outputValue) {
|
|
@@ -251,7 +251,7 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
251
251
|
}
|
|
252
252
|
parts.push({
|
|
253
253
|
functionResponse: {
|
|
254
|
-
...toolCallId != null ? { id: toolCallId } : {},
|
|
254
|
+
...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
|
|
255
255
|
name: toolName,
|
|
256
256
|
response: {
|
|
257
257
|
name: toolName,
|
|
@@ -261,13 +261,13 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
261
261
|
}
|
|
262
262
|
});
|
|
263
263
|
}
|
|
264
|
-
function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
264
|
+
function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
|
|
265
265
|
for (const contentPart of outputValue) {
|
|
266
266
|
switch (contentPart.type) {
|
|
267
267
|
case "text":
|
|
268
268
|
parts.push({
|
|
269
269
|
functionResponse: {
|
|
270
|
-
...toolCallId != null ? { id: toolCallId } : {},
|
|
270
|
+
...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
|
|
271
271
|
name: toolName,
|
|
272
272
|
response: {
|
|
273
273
|
name: toolName,
|
|
@@ -299,7 +299,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
302
|
-
var _a, _b, _c, _d, _e;
|
|
302
|
+
var _a, _b, _c, _d, _e, _f;
|
|
303
303
|
const systemInstructionParts = [];
|
|
304
304
|
const contents = [];
|
|
305
305
|
let systemMessagesAllowed = true;
|
|
@@ -308,6 +308,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
308
308
|
const providerOptionsName = (_c = options == null ? void 0 : options.providerOptionsName) != null ? _c : "google";
|
|
309
309
|
const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
|
|
310
310
|
const onWarning = options == null ? void 0 : options.onWarning;
|
|
311
|
+
const includeFunctionCallIds = (_e = options == null ? void 0 : options.includeFunctionCallIds) != null ? _e : true;
|
|
311
312
|
let sentinelInjected = false;
|
|
312
313
|
const missingSignatureToolNames = [];
|
|
313
314
|
const injectSkipSignature = (toolName) => {
|
|
@@ -424,7 +425,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
424
425
|
}
|
|
425
426
|
return {
|
|
426
427
|
functionCall: {
|
|
427
|
-
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
428
|
+
...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
428
429
|
name: part.toolName,
|
|
429
430
|
args: part.input
|
|
430
431
|
},
|
|
@@ -488,24 +489,26 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
488
489
|
parts,
|
|
489
490
|
part.toolName,
|
|
490
491
|
output.value,
|
|
491
|
-
part.toolCallId
|
|
492
|
+
part.toolCallId,
|
|
493
|
+
includeFunctionCallIds
|
|
492
494
|
);
|
|
493
495
|
} else {
|
|
494
496
|
appendLegacyToolResultParts(
|
|
495
497
|
parts,
|
|
496
498
|
part.toolName,
|
|
497
499
|
output.value,
|
|
498
|
-
part.toolCallId
|
|
500
|
+
part.toolCallId,
|
|
501
|
+
includeFunctionCallIds
|
|
499
502
|
);
|
|
500
503
|
}
|
|
501
504
|
} else {
|
|
502
505
|
parts.push({
|
|
503
506
|
functionResponse: {
|
|
504
|
-
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
507
|
+
...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
505
508
|
name: part.toolName,
|
|
506
509
|
response: {
|
|
507
510
|
name: part.toolName,
|
|
508
|
-
content: output.type === "execution-denied" ? (
|
|
511
|
+
content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : output.value
|
|
509
512
|
}
|
|
510
513
|
}
|
|
511
514
|
});
|
|
@@ -1405,7 +1408,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1405
1408
|
isGemini3Model: usesGemini3Features,
|
|
1406
1409
|
providerOptionsName,
|
|
1407
1410
|
supportsFunctionResponseParts: usesGemini3Features,
|
|
1408
|
-
onWarning: (warning) => warnings.push(warning)
|
|
1411
|
+
onWarning: (warning) => warnings.push(warning),
|
|
1412
|
+
includeFunctionCallIds: !isVertexProvider
|
|
1409
1413
|
}
|
|
1410
1414
|
);
|
|
1411
1415
|
const {
|
|
@@ -5030,7 +5034,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5030
5034
|
};
|
|
5031
5035
|
}
|
|
5032
5036
|
async getArgs(options) {
|
|
5033
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
5037
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
|
|
5034
5038
|
const warnings = [];
|
|
5035
5039
|
const opts = await parseProviderOptions2({
|
|
5036
5040
|
provider: "google",
|
|
@@ -5038,6 +5042,20 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5038
5042
|
schema: googleInteractionsLanguageModelOptions
|
|
5039
5043
|
});
|
|
5040
5044
|
const isAgent = this.agent != null;
|
|
5045
|
+
if (!isAgent) {
|
|
5046
|
+
if (options.frequencyPenalty != null) {
|
|
5047
|
+
warnings.push({
|
|
5048
|
+
type: "unsupported",
|
|
5049
|
+
feature: "frequencyPenalty"
|
|
5050
|
+
});
|
|
5051
|
+
}
|
|
5052
|
+
if (options.presencePenalty != null) {
|
|
5053
|
+
warnings.push({
|
|
5054
|
+
type: "unsupported",
|
|
5055
|
+
feature: "presencePenalty"
|
|
5056
|
+
});
|
|
5057
|
+
}
|
|
5058
|
+
}
|
|
5041
5059
|
const hasTools = options.tools != null && options.tools.length > 0;
|
|
5042
5060
|
let toolsForBody;
|
|
5043
5061
|
let toolChoiceForBody;
|
|
@@ -5121,6 +5139,11 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5121
5139
|
const droppedFields = [];
|
|
5122
5140
|
if (options.temperature != null) droppedFields.push("temperature");
|
|
5123
5141
|
if (options.topP != null) droppedFields.push("topP");
|
|
5142
|
+
if (options.topK != null) droppedFields.push("topK");
|
|
5143
|
+
if (options.frequencyPenalty != null)
|
|
5144
|
+
droppedFields.push("frequencyPenalty");
|
|
5145
|
+
if (options.presencePenalty != null)
|
|
5146
|
+
droppedFields.push("presencePenalty");
|
|
5124
5147
|
if (options.seed != null) droppedFields.push("seed");
|
|
5125
5148
|
if (options.stopSequences != null && options.stopSequences.length > 0) {
|
|
5126
5149
|
droppedFields.push("stopSequences");
|
|
@@ -5143,11 +5166,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5143
5166
|
generationConfig = pruneUndefined({
|
|
5144
5167
|
temperature: (_l = options.temperature) != null ? _l : void 0,
|
|
5145
5168
|
top_p: (_m = options.topP) != null ? _m : void 0,
|
|
5146
|
-
|
|
5169
|
+
top_k: (_n = options.topK) != null ? _n : void 0,
|
|
5170
|
+
seed: (_o = options.seed) != null ? _o : void 0,
|
|
5147
5171
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
5148
|
-
max_output_tokens: (
|
|
5149
|
-
thinking_level: (
|
|
5150
|
-
thinking_summaries: (
|
|
5172
|
+
max_output_tokens: (_p = options.maxOutputTokens) != null ? _p : void 0,
|
|
5173
|
+
thinking_level: (_q = opts == null ? void 0 : opts.thinkingLevel) != null ? _q : void 0,
|
|
5174
|
+
thinking_summaries: (_r = opts == null ? void 0 : opts.thinkingSummaries) != null ? _r : void 0,
|
|
5151
5175
|
tool_choice: toolChoiceForBody
|
|
5152
5176
|
});
|
|
5153
5177
|
if ((opts == null ? void 0 : opts.imageConfig) != null) {
|
|
@@ -5174,9 +5198,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5174
5198
|
if (ac.type === "deep-research") {
|
|
5175
5199
|
agentConfig = pruneUndefined({
|
|
5176
5200
|
type: "deep-research",
|
|
5177
|
-
thinking_summaries: (
|
|
5178
|
-
visualization: (
|
|
5179
|
-
collaborative_planning: (
|
|
5201
|
+
thinking_summaries: (_s = ac.thinkingSummaries) != null ? _s : void 0,
|
|
5202
|
+
visualization: (_t = ac.visualization) != null ? _t : void 0,
|
|
5203
|
+
collaborative_planning: (_u = ac.collaborativePlanning) != null ? _u : void 0
|
|
5180
5204
|
});
|
|
5181
5205
|
} else if (ac.type === "dynamic") {
|
|
5182
5206
|
agentConfig = { type: "dynamic" };
|
|
@@ -5193,7 +5217,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5193
5217
|
environment = opts.environment;
|
|
5194
5218
|
} else {
|
|
5195
5219
|
const env = opts.environment;
|
|
5196
|
-
const sources = (
|
|
5220
|
+
const sources = (_v = env.sources) == null ? void 0 : _v.map((s) => {
|
|
5197
5221
|
var _a2;
|
|
5198
5222
|
if (s.type === "inline") {
|
|
5199
5223
|
return {
|
|
@@ -5238,20 +5262,20 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5238
5262
|
tools: toolsForBody,
|
|
5239
5263
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5240
5264
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5241
|
-
previous_interaction_id: (
|
|
5242
|
-
service_tier: (
|
|
5243
|
-
store: (
|
|
5265
|
+
previous_interaction_id: (_w = opts == null ? void 0 : opts.previousInteractionId) != null ? _w : void 0,
|
|
5266
|
+
service_tier: (_x = opts == null ? void 0 : opts.serviceTier) != null ? _x : void 0,
|
|
5267
|
+
store: (_y = opts == null ? void 0 : opts.store) != null ? _y : void 0,
|
|
5244
5268
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5245
5269
|
agent_config: agentConfig,
|
|
5246
5270
|
environment,
|
|
5247
|
-
background: (
|
|
5271
|
+
background: (_z = opts == null ? void 0 : opts.background) != null ? _z : void 0
|
|
5248
5272
|
});
|
|
5249
5273
|
return {
|
|
5250
5274
|
args,
|
|
5251
5275
|
warnings,
|
|
5252
5276
|
isAgent,
|
|
5253
5277
|
isBackground: (opts == null ? void 0 : opts.background) === true,
|
|
5254
|
-
pollingTimeoutMs: (
|
|
5278
|
+
pollingTimeoutMs: (_A = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _A : void 0
|
|
5255
5279
|
};
|
|
5256
5280
|
}
|
|
5257
5281
|
async doGenerate(options) {
|