@ai-sdk/google 4.0.0-beta.44 → 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 +25 -0
- package/README.md +4 -4
- package/dist/index.d.ts +40 -40
- package/dist/index.js +102 -108
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +16 -16
- package/dist/internal/index.js +62 -62
- package/dist/internal/index.js.map +1 -1
- package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +36 -36
- package/package.json +7 -6
- package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +6 -6
- package/src/{convert-to-google-generative-ai-messages.ts → convert-to-google-messages.ts} +15 -15
- package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +10 -16
- package/src/{google-generative-ai-embedding-options.ts → google-embedding-options.ts} +1 -1
- package/src/{google-generative-ai-files.ts → google-files.ts} +3 -3
- package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +16 -20
- package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
- package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +29 -34
- package/src/{google-generative-ai-options.ts → google-options.ts} +2 -2
- package/src/google-prepare-tools.ts +9 -5
- package/src/google-prompt.ts +82 -0
- package/src/google-provider.ts +42 -46
- package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +5 -5
- package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +1 -1
- package/src/index.ts +28 -10
- package/src/internal/index.ts +2 -2
- package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +1 -1
- 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/src/google-generative-ai-prompt.ts +0 -82
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
|
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GroundingMetadataSchema,
|
|
3
|
-
PromptFeedbackSchema,
|
|
4
|
-
UrlContextMetadataSchema,
|
|
5
|
-
type SafetyRatingSchema,
|
|
6
|
-
UsageMetadataSchema,
|
|
7
|
-
} from './google-generative-ai-language-model';
|
|
8
|
-
|
|
9
|
-
export type GoogleGenerativeAIPrompt = {
|
|
10
|
-
systemInstruction?: GoogleGenerativeAISystemInstruction;
|
|
11
|
-
contents: Array<GoogleGenerativeAIContent>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type GoogleGenerativeAISystemInstruction = {
|
|
15
|
-
parts: Array<{ text: string }>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type GoogleGenerativeAIContent = {
|
|
19
|
-
role: 'user' | 'model';
|
|
20
|
-
parts: Array<GoogleGenerativeAIContentPart>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type GoogleGenerativeAIContentPart =
|
|
24
|
-
| { text: string; thought?: boolean; thoughtSignature?: string }
|
|
25
|
-
| {
|
|
26
|
-
inlineData: { mimeType: string; data: string };
|
|
27
|
-
thought?: boolean;
|
|
28
|
-
thoughtSignature?: string;
|
|
29
|
-
}
|
|
30
|
-
| { functionCall: { name: string; args: unknown }; thoughtSignature?: string }
|
|
31
|
-
| {
|
|
32
|
-
functionResponse: {
|
|
33
|
-
name: string;
|
|
34
|
-
response: unknown;
|
|
35
|
-
parts?: Array<GoogleGenerativeAIFunctionResponsePart>;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
| {
|
|
39
|
-
fileData: { mimeType: string; fileUri: string };
|
|
40
|
-
thought?: boolean;
|
|
41
|
-
thoughtSignature?: string;
|
|
42
|
-
}
|
|
43
|
-
| {
|
|
44
|
-
toolCall: {
|
|
45
|
-
toolType: string;
|
|
46
|
-
args?: unknown;
|
|
47
|
-
id: string;
|
|
48
|
-
};
|
|
49
|
-
thoughtSignature?: string;
|
|
50
|
-
}
|
|
51
|
-
| {
|
|
52
|
-
toolResponse: {
|
|
53
|
-
toolType: string;
|
|
54
|
-
response?: unknown;
|
|
55
|
-
id: string;
|
|
56
|
-
};
|
|
57
|
-
thoughtSignature?: string;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export type GoogleGenerativeAIFunctionResponsePart = {
|
|
61
|
-
inlineData: { mimeType: string; data: string };
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export type GoogleGenerativeAIGroundingMetadata = GroundingMetadataSchema;
|
|
65
|
-
|
|
66
|
-
export type GoogleGenerativeAIUrlContextMetadata = UrlContextMetadataSchema;
|
|
67
|
-
|
|
68
|
-
export type GoogleGenerativeAISafetyRating = SafetyRatingSchema;
|
|
69
|
-
|
|
70
|
-
export type GoogleGenerativeAIPromptFeedback = PromptFeedbackSchema;
|
|
71
|
-
|
|
72
|
-
export type GoogleGenerativeAIUsageMetadata = UsageMetadataSchema;
|
|
73
|
-
|
|
74
|
-
export interface GoogleGenerativeAIProviderMetadata {
|
|
75
|
-
promptFeedback: GoogleGenerativeAIPromptFeedback | null;
|
|
76
|
-
groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
|
|
77
|
-
urlContextMetadata: GoogleGenerativeAIUrlContextMetadata | null;
|
|
78
|
-
safetyRatings: GoogleGenerativeAISafetyRating[] | null;
|
|
79
|
-
usageMetadata: GoogleGenerativeAIUsageMetadata | null;
|
|
80
|
-
finishMessage: string | null;
|
|
81
|
-
serviceTier: string | null;
|
|
82
|
-
}
|