@ai-sdk/google 3.0.68 → 3.0.71
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 +26 -0
- package/dist/index.js +56 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -20
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +46 -19
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +46 -19
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/google-generative-ai-language-model.ts +36 -6
- package/src/google-prepare-tools.ts +6 -2
- package/src/interactions/convert-to-google-interactions-input.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.71",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@ai-sdk/provider": "3.0.10",
|
|
40
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
40
|
+
"@ai-sdk/provider-utils": "4.0.27"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|
|
@@ -181,6 +181,7 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
181
181
|
tools,
|
|
182
182
|
toolChoice,
|
|
183
183
|
modelId: this.modelId,
|
|
184
|
+
isVertexProvider,
|
|
184
185
|
});
|
|
185
186
|
|
|
186
187
|
const streamFunctionCallArguments =
|
|
@@ -345,16 +346,12 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
345
346
|
providerMetadata: thoughtSignatureMetadata,
|
|
346
347
|
});
|
|
347
348
|
}
|
|
348
|
-
} else if (
|
|
349
|
-
'functionCall' in part &&
|
|
350
|
-
part.functionCall.name != null &&
|
|
351
|
-
part.functionCall.args != null
|
|
352
|
-
) {
|
|
349
|
+
} else if ('functionCall' in part && part.functionCall.name != null) {
|
|
353
350
|
content.push({
|
|
354
351
|
type: 'tool-call' as const,
|
|
355
352
|
toolCallId: this.config.generateId(),
|
|
356
353
|
toolName: part.functionCall.name,
|
|
357
|
-
input: JSON.stringify(part.functionCall.args),
|
|
354
|
+
input: JSON.stringify(part.functionCall.args ?? {}),
|
|
358
355
|
providerMetadata: part.thoughtSignature
|
|
359
356
|
? {
|
|
360
357
|
[providerOptionsName]: {
|
|
@@ -818,6 +815,13 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
818
815
|
part.functionCall.name != null &&
|
|
819
816
|
part.functionCall.args != null &&
|
|
820
817
|
part.functionCall.partialArgs == null;
|
|
818
|
+
// Single-chunk no-args call: `{ name: 'X' }` with no `args`,
|
|
819
|
+
// `partialArgs`, or `willContinue`. Carries `thoughtSignature`.
|
|
820
|
+
const isNoArgsCompleteCall =
|
|
821
|
+
part.functionCall.name != null &&
|
|
822
|
+
part.functionCall.args == null &&
|
|
823
|
+
part.functionCall.partialArgs == null &&
|
|
824
|
+
part.functionCall.willContinue !== true;
|
|
821
825
|
|
|
822
826
|
if (isStreamingChunk) {
|
|
823
827
|
if (
|
|
@@ -941,6 +945,32 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
941
945
|
providerMetadata: providerMeta,
|
|
942
946
|
});
|
|
943
947
|
|
|
948
|
+
hasToolCalls = true;
|
|
949
|
+
} else if (isNoArgsCompleteCall) {
|
|
950
|
+
const toolCallId = generateId();
|
|
951
|
+
const toolName = part.functionCall.name!;
|
|
952
|
+
|
|
953
|
+
controller.enqueue({
|
|
954
|
+
type: 'tool-input-start',
|
|
955
|
+
id: toolCallId,
|
|
956
|
+
toolName,
|
|
957
|
+
providerMetadata: providerMeta,
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
controller.enqueue({
|
|
961
|
+
type: 'tool-input-end',
|
|
962
|
+
id: toolCallId,
|
|
963
|
+
providerMetadata: providerMeta,
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
controller.enqueue({
|
|
967
|
+
type: 'tool-call',
|
|
968
|
+
toolCallId,
|
|
969
|
+
toolName,
|
|
970
|
+
input: '{}',
|
|
971
|
+
providerMetadata: providerMeta,
|
|
972
|
+
});
|
|
973
|
+
|
|
944
974
|
hasToolCalls = true;
|
|
945
975
|
}
|
|
946
976
|
}
|
|
@@ -10,10 +10,12 @@ export function prepareTools({
|
|
|
10
10
|
tools,
|
|
11
11
|
toolChoice,
|
|
12
12
|
modelId,
|
|
13
|
+
isVertexProvider = false,
|
|
13
14
|
}: {
|
|
14
15
|
tools: LanguageModelV3CallOptions['tools'];
|
|
15
16
|
toolChoice?: LanguageModelV3CallOptions['toolChoice'];
|
|
16
17
|
modelId: GoogleGenerativeAIModelId;
|
|
18
|
+
isVertexProvider?: boolean;
|
|
17
19
|
}): {
|
|
18
20
|
tools:
|
|
19
21
|
| Array<
|
|
@@ -202,10 +204,12 @@ export function prepareTools({
|
|
|
202
204
|
mode: 'VALIDATED' | 'ANY' | 'NONE';
|
|
203
205
|
allowedFunctionNames?: string[];
|
|
204
206
|
};
|
|
205
|
-
includeServerSideToolInvocations
|
|
207
|
+
includeServerSideToolInvocations?: true;
|
|
206
208
|
} = {
|
|
207
209
|
functionCallingConfig: { mode: 'VALIDATED' },
|
|
208
|
-
|
|
210
|
+
...(!isVertexProvider && {
|
|
211
|
+
includeServerSideToolInvocations: true,
|
|
212
|
+
}),
|
|
209
213
|
};
|
|
210
214
|
|
|
211
215
|
if (toolChoice != null) {
|
|
@@ -164,6 +164,15 @@ export function convertToGoogleInteractionsInput({
|
|
|
164
164
|
? [{ type: 'text', text: part.text }]
|
|
165
165
|
: undefined,
|
|
166
166
|
});
|
|
167
|
+
} else if (part.type === 'file') {
|
|
168
|
+
const fileBlock = convertFilePartToContent({
|
|
169
|
+
part,
|
|
170
|
+
warnings,
|
|
171
|
+
mediaResolution,
|
|
172
|
+
});
|
|
173
|
+
if (fileBlock != null) {
|
|
174
|
+
content.push(fileBlock);
|
|
175
|
+
}
|
|
167
176
|
} else if (part.type === 'tool-call') {
|
|
168
177
|
const signature = part.providerOptions?.google?.signature as
|
|
169
178
|
| string
|