@ai-sdk/google 4.0.0-beta.45 → 4.0.0-beta.46
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 +14 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +57 -54
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +7 -7
- package/dist/internal/index.js +40 -37
- package/dist/internal/index.js.map +1 -1
- package/package.json +5 -4
- package/src/convert-to-google-messages.ts +1 -1
- package/src/google-language-model.ts +1 -0
- package/src/google-prepare-tools.ts +6 -2
- package/src/tool/code-execution.ts +2 -2
- package/src/tool/enterprise-web-search.ts +9 -3
- package/src/tool/file-search.ts +5 -7
- package/src/tool/google-maps.ts +3 -2
- package/src/tool/google-search.ts +10 -11
- package/src/tool/url-context.ts +4 -2
- package/src/tool/vertex-rag-store.ts +9 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.46",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ai-sdk/provider": "
|
|
39
|
-
"@ai-sdk/provider
|
|
38
|
+
"@ai-sdk/provider-utils": "5.0.0-beta.27",
|
|
39
|
+
"@ai-sdk/provider": "4.0.0-beta.12"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "20.17.24",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"node": ">=18"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
|
-
"access": "public"
|
|
56
|
+
"access": "public",
|
|
57
|
+
"provenance": true
|
|
57
58
|
},
|
|
58
59
|
"homepage": "https://ai-sdk.dev/docs",
|
|
59
60
|
"repository": {
|
|
@@ -478,7 +478,7 @@ export function convertToGoogleMessages(
|
|
|
478
478
|
name: part.toolName,
|
|
479
479
|
content:
|
|
480
480
|
output.type === 'execution-denied'
|
|
481
|
-
? (output.reason ?? 'Tool execution denied.')
|
|
481
|
+
? (output.reason ?? 'Tool call execution denied.')
|
|
482
482
|
: output.value,
|
|
483
483
|
},
|
|
484
484
|
},
|
|
@@ -10,10 +10,12 @@ export function prepareTools({
|
|
|
10
10
|
tools,
|
|
11
11
|
toolChoice,
|
|
12
12
|
modelId,
|
|
13
|
+
isVertexProvider = false,
|
|
13
14
|
}: {
|
|
14
15
|
tools: LanguageModelV4CallOptions['tools'];
|
|
15
16
|
toolChoice?: LanguageModelV4CallOptions['toolChoice'];
|
|
16
17
|
modelId: GoogleModelId;
|
|
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) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createProviderExecutedToolFactory } from '@ai-sdk/provider-utils';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ import { z } from 'zod/v4';
|
|
|
10
10
|
* @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
|
|
11
11
|
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
|
|
12
12
|
*/
|
|
13
|
-
export const codeExecution =
|
|
13
|
+
export const codeExecution = createProviderExecutedToolFactory<
|
|
14
14
|
{
|
|
15
15
|
language: string;
|
|
16
16
|
code: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -7,12 +7,18 @@ import { z } from 'zod/v4';
|
|
|
7
7
|
|
|
8
8
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
|
|
9
9
|
|
|
10
|
-
export const enterpriseWebSearch =
|
|
10
|
+
export const enterpriseWebSearch = createProviderExecutedToolFactory<
|
|
11
11
|
{
|
|
12
12
|
// Enterprise Web Search does not have any input schema
|
|
13
13
|
},
|
|
14
|
-
{
|
|
14
|
+
{
|
|
15
|
+
// Enterprise Web Search does not have any output parameters
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
// Enterprise Web Search does not have any configuration options
|
|
19
|
+
}
|
|
15
20
|
>({
|
|
16
21
|
id: 'google.enterprise_web_search',
|
|
17
22
|
inputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
23
|
+
outputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
18
24
|
});
|
package/src/tool/file-search.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -38,14 +38,12 @@ const fileSearchArgsBaseSchema = z
|
|
|
38
38
|
|
|
39
39
|
export type GoogleFileSearchToolArgs = z.infer<typeof fileSearchArgsBaseSchema>;
|
|
40
40
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
export const fileSearch = createProviderToolFactory<
|
|
41
|
+
export const fileSearch = createProviderExecutedToolFactory<
|
|
42
|
+
{},
|
|
46
43
|
{},
|
|
47
44
|
GoogleFileSearchToolArgs
|
|
48
45
|
>({
|
|
49
46
|
id: 'google.file_search',
|
|
50
|
-
inputSchema:
|
|
47
|
+
inputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
48
|
+
outputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
51
49
|
});
|
package/src/tool/google-maps.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -8,7 +8,8 @@ import { z } from 'zod/v4';
|
|
|
8
8
|
// https://ai.google.dev/gemini-api/docs/maps-grounding
|
|
9
9
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
|
|
10
10
|
|
|
11
|
-
export const googleMaps =
|
|
11
|
+
export const googleMaps = createProviderExecutedToolFactory<{}, {}, {}>({
|
|
12
12
|
id: 'google.google_maps',
|
|
13
13
|
inputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
14
|
+
outputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
14
15
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
@@ -31,13 +31,12 @@ export type GoogleSearchToolArgs = z.infer<
|
|
|
31
31
|
typeof googleSearchToolArgsBaseSchema
|
|
32
32
|
>;
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
34
|
+
export const googleSearch = createProviderExecutedToolFactory<
|
|
35
|
+
{},
|
|
36
|
+
{},
|
|
37
|
+
GoogleSearchToolArgs
|
|
38
|
+
>({
|
|
39
|
+
id: 'google.google_search',
|
|
40
|
+
inputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
41
|
+
outputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
42
|
+
});
|
package/src/tool/url-context.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
3
|
lazySchema,
|
|
4
4
|
zodSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
6
6
|
import { z } from 'zod/v4';
|
|
7
7
|
|
|
8
|
-
export const urlContext =
|
|
8
|
+
export const urlContext = createProviderExecutedToolFactory<
|
|
9
9
|
{
|
|
10
10
|
// Url context does not have any input schema, it will directly use the url from the prompt
|
|
11
11
|
},
|
|
12
|
+
{},
|
|
12
13
|
{}
|
|
13
14
|
>({
|
|
14
15
|
id: 'google.url_context',
|
|
15
16
|
inputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
17
|
+
outputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
16
18
|
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createProviderExecutedToolFactory,
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
2
6
|
import { z } from 'zod/v4';
|
|
3
7
|
|
|
4
8
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/rag-engine/use-vertexai-search#generate-content-using-gemini-api
|
|
@@ -9,7 +13,8 @@ import { z } from 'zod/v4';
|
|
|
9
13
|
*
|
|
10
14
|
* @note Only works with Vertex Gemini models.
|
|
11
15
|
*/
|
|
12
|
-
export const vertexRagStore =
|
|
16
|
+
export const vertexRagStore = createProviderExecutedToolFactory<
|
|
17
|
+
{},
|
|
13
18
|
{},
|
|
14
19
|
{
|
|
15
20
|
/**
|
|
@@ -24,8 +29,6 @@ export const vertexRagStore = createProviderToolFactory<
|
|
|
24
29
|
}
|
|
25
30
|
>({
|
|
26
31
|
id: 'google.vertex_rag_store',
|
|
27
|
-
inputSchema: z.object({
|
|
28
|
-
|
|
29
|
-
topK: z.number().optional(),
|
|
30
|
-
}),
|
|
32
|
+
inputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
33
|
+
outputSchema: lazySchema(() => zodSchema(z.object({}))),
|
|
31
34
|
});
|