@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.js
CHANGED
|
@@ -230,7 +230,7 @@ function convertUrlToolResultPart(url) {
|
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
-
function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
233
|
+
function appendToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
|
|
234
234
|
const functionResponseParts = [];
|
|
235
235
|
const responseTextParts = [];
|
|
236
236
|
for (const contentPart of outputValue) {
|
|
@@ -269,7 +269,7 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
269
269
|
}
|
|
270
270
|
parts.push({
|
|
271
271
|
functionResponse: {
|
|
272
|
-
...toolCallId != null ? { id: toolCallId } : {},
|
|
272
|
+
...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
|
|
273
273
|
name: toolName,
|
|
274
274
|
response: {
|
|
275
275
|
name: toolName,
|
|
@@ -279,13 +279,13 @@ function appendToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
282
|
+
function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId, includeFunctionCallIds = true) {
|
|
283
283
|
for (const contentPart of outputValue) {
|
|
284
284
|
switch (contentPart.type) {
|
|
285
285
|
case "text":
|
|
286
286
|
parts.push({
|
|
287
287
|
functionResponse: {
|
|
288
|
-
...toolCallId != null ? { id: toolCallId } : {},
|
|
288
|
+
...includeFunctionCallIds && toolCallId != null ? { id: toolCallId } : {},
|
|
289
289
|
name: toolName,
|
|
290
290
|
response: {
|
|
291
291
|
name: toolName,
|
|
@@ -317,7 +317,7 @@ function appendLegacyToolResultParts(parts, toolName, outputValue, toolCallId) {
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
320
|
-
var _a, _b, _c, _d, _e;
|
|
320
|
+
var _a, _b, _c, _d, _e, _f;
|
|
321
321
|
const systemInstructionParts = [];
|
|
322
322
|
const contents = [];
|
|
323
323
|
let systemMessagesAllowed = true;
|
|
@@ -326,6 +326,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
326
326
|
const providerOptionsName = (_c = options == null ? void 0 : options.providerOptionsName) != null ? _c : "google";
|
|
327
327
|
const supportsFunctionResponseParts = (_d = options == null ? void 0 : options.supportsFunctionResponseParts) != null ? _d : true;
|
|
328
328
|
const onWarning = options == null ? void 0 : options.onWarning;
|
|
329
|
+
const includeFunctionCallIds = (_e = options == null ? void 0 : options.includeFunctionCallIds) != null ? _e : true;
|
|
329
330
|
let sentinelInjected = false;
|
|
330
331
|
const missingSignatureToolNames = [];
|
|
331
332
|
const injectSkipSignature = (toolName) => {
|
|
@@ -442,7 +443,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
442
443
|
}
|
|
443
444
|
return {
|
|
444
445
|
functionCall: {
|
|
445
|
-
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
446
|
+
...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
446
447
|
name: part.toolName,
|
|
447
448
|
args: part.input
|
|
448
449
|
},
|
|
@@ -506,24 +507,26 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
506
507
|
parts,
|
|
507
508
|
part.toolName,
|
|
508
509
|
output.value,
|
|
509
|
-
part.toolCallId
|
|
510
|
+
part.toolCallId,
|
|
511
|
+
includeFunctionCallIds
|
|
510
512
|
);
|
|
511
513
|
} else {
|
|
512
514
|
appendLegacyToolResultParts(
|
|
513
515
|
parts,
|
|
514
516
|
part.toolName,
|
|
515
517
|
output.value,
|
|
516
|
-
part.toolCallId
|
|
518
|
+
part.toolCallId,
|
|
519
|
+
includeFunctionCallIds
|
|
517
520
|
);
|
|
518
521
|
}
|
|
519
522
|
} else {
|
|
520
523
|
parts.push({
|
|
521
524
|
functionResponse: {
|
|
522
|
-
...part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
525
|
+
...includeFunctionCallIds && part.toolCallId != null ? { id: part.toolCallId } : {},
|
|
523
526
|
name: part.toolName,
|
|
524
527
|
response: {
|
|
525
528
|
name: part.toolName,
|
|
526
|
-
content: output.type === "execution-denied" ? (
|
|
529
|
+
content: output.type === "execution-denied" ? (_f = output.reason) != null ? _f : "Tool call execution denied." : output.value
|
|
527
530
|
}
|
|
528
531
|
}
|
|
529
532
|
});
|
|
@@ -1414,7 +1417,8 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
1414
1417
|
isGemini3Model: usesGemini3Features,
|
|
1415
1418
|
providerOptionsName,
|
|
1416
1419
|
supportsFunctionResponseParts: usesGemini3Features,
|
|
1417
|
-
onWarning: (warning) => warnings.push(warning)
|
|
1420
|
+
onWarning: (warning) => warnings.push(warning),
|
|
1421
|
+
includeFunctionCallIds: !isVertexProvider
|
|
1418
1422
|
}
|
|
1419
1423
|
);
|
|
1420
1424
|
const {
|
|
@@ -4991,7 +4995,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
4991
4995
|
};
|
|
4992
4996
|
}
|
|
4993
4997
|
async getArgs(options) {
|
|
4994
|
-
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;
|
|
4998
|
+
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;
|
|
4995
4999
|
const warnings = [];
|
|
4996
5000
|
const opts = await (0, import_provider_utils18.parseProviderOptions)({
|
|
4997
5001
|
provider: "google",
|
|
@@ -4999,6 +5003,20 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
4999
5003
|
schema: googleInteractionsLanguageModelOptions
|
|
5000
5004
|
});
|
|
5001
5005
|
const isAgent = this.agent != null;
|
|
5006
|
+
if (!isAgent) {
|
|
5007
|
+
if (options.frequencyPenalty != null) {
|
|
5008
|
+
warnings.push({
|
|
5009
|
+
type: "unsupported",
|
|
5010
|
+
feature: "frequencyPenalty"
|
|
5011
|
+
});
|
|
5012
|
+
}
|
|
5013
|
+
if (options.presencePenalty != null) {
|
|
5014
|
+
warnings.push({
|
|
5015
|
+
type: "unsupported",
|
|
5016
|
+
feature: "presencePenalty"
|
|
5017
|
+
});
|
|
5018
|
+
}
|
|
5019
|
+
}
|
|
5002
5020
|
const hasTools = options.tools != null && options.tools.length > 0;
|
|
5003
5021
|
let toolsForBody;
|
|
5004
5022
|
let toolChoiceForBody;
|
|
@@ -5082,6 +5100,11 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5082
5100
|
const droppedFields = [];
|
|
5083
5101
|
if (options.temperature != null) droppedFields.push("temperature");
|
|
5084
5102
|
if (options.topP != null) droppedFields.push("topP");
|
|
5103
|
+
if (options.topK != null) droppedFields.push("topK");
|
|
5104
|
+
if (options.frequencyPenalty != null)
|
|
5105
|
+
droppedFields.push("frequencyPenalty");
|
|
5106
|
+
if (options.presencePenalty != null)
|
|
5107
|
+
droppedFields.push("presencePenalty");
|
|
5085
5108
|
if (options.seed != null) droppedFields.push("seed");
|
|
5086
5109
|
if (options.stopSequences != null && options.stopSequences.length > 0) {
|
|
5087
5110
|
droppedFields.push("stopSequences");
|
|
@@ -5104,11 +5127,12 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5104
5127
|
generationConfig = pruneUndefined({
|
|
5105
5128
|
temperature: (_l = options.temperature) != null ? _l : void 0,
|
|
5106
5129
|
top_p: (_m = options.topP) != null ? _m : void 0,
|
|
5107
|
-
|
|
5130
|
+
top_k: (_n = options.topK) != null ? _n : void 0,
|
|
5131
|
+
seed: (_o = options.seed) != null ? _o : void 0,
|
|
5108
5132
|
stop_sequences: options.stopSequences != null && options.stopSequences.length > 0 ? options.stopSequences : void 0,
|
|
5109
|
-
max_output_tokens: (
|
|
5110
|
-
thinking_level: (
|
|
5111
|
-
thinking_summaries: (
|
|
5133
|
+
max_output_tokens: (_p = options.maxOutputTokens) != null ? _p : void 0,
|
|
5134
|
+
thinking_level: (_q = opts == null ? void 0 : opts.thinkingLevel) != null ? _q : void 0,
|
|
5135
|
+
thinking_summaries: (_r = opts == null ? void 0 : opts.thinkingSummaries) != null ? _r : void 0,
|
|
5112
5136
|
tool_choice: toolChoiceForBody
|
|
5113
5137
|
});
|
|
5114
5138
|
if ((opts == null ? void 0 : opts.imageConfig) != null) {
|
|
@@ -5135,9 +5159,9 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5135
5159
|
if (ac.type === "deep-research") {
|
|
5136
5160
|
agentConfig = pruneUndefined({
|
|
5137
5161
|
type: "deep-research",
|
|
5138
|
-
thinking_summaries: (
|
|
5139
|
-
visualization: (
|
|
5140
|
-
collaborative_planning: (
|
|
5162
|
+
thinking_summaries: (_s = ac.thinkingSummaries) != null ? _s : void 0,
|
|
5163
|
+
visualization: (_t = ac.visualization) != null ? _t : void 0,
|
|
5164
|
+
collaborative_planning: (_u = ac.collaborativePlanning) != null ? _u : void 0
|
|
5141
5165
|
});
|
|
5142
5166
|
} else if (ac.type === "dynamic") {
|
|
5143
5167
|
agentConfig = { type: "dynamic" };
|
|
@@ -5154,7 +5178,7 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5154
5178
|
environment = opts.environment;
|
|
5155
5179
|
} else {
|
|
5156
5180
|
const env = opts.environment;
|
|
5157
|
-
const sources = (
|
|
5181
|
+
const sources = (_v = env.sources) == null ? void 0 : _v.map((s) => {
|
|
5158
5182
|
var _a2;
|
|
5159
5183
|
if (s.type === "inline") {
|
|
5160
5184
|
return {
|
|
@@ -5199,20 +5223,20 @@ var GoogleInteractionsLanguageModel = class {
|
|
|
5199
5223
|
tools: toolsForBody,
|
|
5200
5224
|
response_format: responseFormatEntries.length > 0 ? responseFormatEntries : void 0,
|
|
5201
5225
|
response_modalities: (opts == null ? void 0 : opts.responseModalities) != null ? opts.responseModalities : void 0,
|
|
5202
|
-
previous_interaction_id: (
|
|
5203
|
-
service_tier: (
|
|
5204
|
-
store: (
|
|
5226
|
+
previous_interaction_id: (_w = opts == null ? void 0 : opts.previousInteractionId) != null ? _w : void 0,
|
|
5227
|
+
service_tier: (_x = opts == null ? void 0 : opts.serviceTier) != null ? _x : void 0,
|
|
5228
|
+
store: (_y = opts == null ? void 0 : opts.store) != null ? _y : void 0,
|
|
5205
5229
|
generation_config: generationConfig != null && Object.keys(generationConfig).length > 0 ? generationConfig : void 0,
|
|
5206
5230
|
agent_config: agentConfig,
|
|
5207
5231
|
environment,
|
|
5208
|
-
background: (
|
|
5232
|
+
background: (_z = opts == null ? void 0 : opts.background) != null ? _z : void 0
|
|
5209
5233
|
});
|
|
5210
5234
|
return {
|
|
5211
5235
|
args,
|
|
5212
5236
|
warnings,
|
|
5213
5237
|
isAgent,
|
|
5214
5238
|
isBackground: (opts == null ? void 0 : opts.background) === true,
|
|
5215
|
-
pollingTimeoutMs: (
|
|
5239
|
+
pollingTimeoutMs: (_A = opts == null ? void 0 : opts.pollingTimeoutMs) != null ? _A : void 0
|
|
5216
5240
|
};
|
|
5217
5241
|
}
|
|
5218
5242
|
async doGenerate(options) {
|