cloudassist-ai-provider 0.0.1 → 0.0.2

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.
Files changed (112) hide show
  1. package/dist/index.d.ts +326 -9
  2. package/dist/index.js +2187 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +86 -34
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/internal/index.d.ts +262 -4
  7. package/dist/internal/index.js +1850 -2
  8. package/dist/internal/index.js.map +1 -1
  9. package/dist/internal/index.mjs +79 -29
  10. package/dist/internal/index.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/dist/convert-json-schema-to-openapi-schema.d.ts +0 -6
  13. package/dist/convert-json-schema-to-openapi-schema.d.ts.map +0 -1
  14. package/dist/convert-json-schema-to-openapi-schema.js +0 -108
  15. package/dist/convert-json-schema-to-openapi-schema.test.d.ts +0 -2
  16. package/dist/convert-json-schema-to-openapi-schema.test.d.ts.map +0 -1
  17. package/dist/convert-json-schema-to-openapi-schema.test.js +0 -630
  18. package/dist/convert-to-google-generative-ai-messages.d.ts +0 -7
  19. package/dist/convert-to-google-generative-ai-messages.d.ts.map +0 -1
  20. package/dist/convert-to-google-generative-ai-messages.js +0 -195
  21. package/dist/convert-to-google-generative-ai-messages.test.d.ts +0 -2
  22. package/dist/convert-to-google-generative-ai-messages.test.d.ts.map +0 -1
  23. package/dist/convert-to-google-generative-ai-messages.test.js +0 -456
  24. package/dist/get-model-path.d.ts +0 -2
  25. package/dist/get-model-path.d.ts.map +0 -1
  26. package/dist/get-model-path.js +0 -3
  27. package/dist/get-model-path.test.d.ts +0 -2
  28. package/dist/get-model-path.test.d.ts.map +0 -1
  29. package/dist/get-model-path.test.js +0 -11
  30. package/dist/google-error.d.ts +0 -12
  31. package/dist/google-error.d.ts.map +0 -1
  32. package/dist/google-error.js +0 -13
  33. package/dist/google-generative-ai-embedding-model.d.ts +0 -21
  34. package/dist/google-generative-ai-embedding-model.d.ts.map +0 -1
  35. package/dist/google-generative-ai-embedding-model.js +0 -88
  36. package/dist/google-generative-ai-embedding-model.test.d.ts +0 -2
  37. package/dist/google-generative-ai-embedding-model.test.d.ts.map +0 -1
  38. package/dist/google-generative-ai-embedding-model.test.js +0 -148
  39. package/dist/google-generative-ai-embedding-options.d.ts +0 -8
  40. package/dist/google-generative-ai-embedding-options.d.ts.map +0 -1
  41. package/dist/google-generative-ai-embedding-options.js +0 -33
  42. package/dist/google-generative-ai-image-model.d.ts +0 -31
  43. package/dist/google-generative-ai-image-model.d.ts.map +0 -1
  44. package/dist/google-generative-ai-image-model.js +0 -96
  45. package/dist/google-generative-ai-image-model.test.d.ts +0 -2
  46. package/dist/google-generative-ai-image-model.test.d.ts.map +0 -1
  47. package/dist/google-generative-ai-image-model.test.js +0 -252
  48. package/dist/google-generative-ai-image-settings.d.ts +0 -8
  49. package/dist/google-generative-ai-image-settings.d.ts.map +0 -1
  50. package/dist/google-generative-ai-image-settings.js +0 -1
  51. package/dist/google-generative-ai-language-model.d.ts +0 -183
  52. package/dist/google-generative-ai-language-model.d.ts.map +0 -1
  53. package/dist/google-generative-ai-language-model.js +0 -1001
  54. package/dist/google-generative-ai-language-model.test.d.ts +0 -2
  55. package/dist/google-generative-ai-language-model.test.d.ts.map +0 -1
  56. package/dist/google-generative-ai-language-model.test.js +0 -3463
  57. package/dist/google-generative-ai-options.d.ts +0 -37
  58. package/dist/google-generative-ai-options.d.ts.map +0 -1
  59. package/dist/google-generative-ai-options.js +0 -149
  60. package/dist/google-generative-ai-prompt.d.ts +0 -52
  61. package/dist/google-generative-ai-prompt.d.ts.map +0 -1
  62. package/dist/google-generative-ai-prompt.js +0 -1
  63. package/dist/google-prepare-tools.d.ts +0 -27
  64. package/dist/google-prepare-tools.d.ts.map +0 -1
  65. package/dist/google-prepare-tools.js +0 -219
  66. package/dist/google-prepare-tools.test.d.ts +0 -2
  67. package/dist/google-prepare-tools.test.d.ts.map +0 -1
  68. package/dist/google-prepare-tools.test.js +0 -447
  69. package/dist/google-provider.d.ts +0 -65
  70. package/dist/google-provider.d.ts.map +0 -1
  71. package/dist/google-provider.js +0 -74
  72. package/dist/google-provider.test.d.ts +0 -2
  73. package/dist/google-provider.test.d.ts.map +0 -1
  74. package/dist/google-provider.test.js +0 -234
  75. package/dist/google-supported-file-url.d.ts +0 -2
  76. package/dist/google-supported-file-url.d.ts.map +0 -1
  77. package/dist/google-supported-file-url.js +0 -13
  78. package/dist/google-supported-file-url.test.d.ts +0 -2
  79. package/dist/google-supported-file-url.test.d.ts.map +0 -1
  80. package/dist/google-supported-file-url.test.js +0 -45
  81. package/dist/google-tools.d.ts +0 -76
  82. package/dist/google-tools.d.ts.map +0 -1
  83. package/dist/google-tools.js +0 -65
  84. package/dist/index.d.ts.map +0 -1
  85. package/dist/internal/index.d.ts.map +0 -1
  86. package/dist/map-google-generative-ai-finish-reason.d.ts +0 -6
  87. package/dist/map-google-generative-ai-finish-reason.d.ts.map +0 -1
  88. package/dist/map-google-generative-ai-finish-reason.js +0 -22
  89. package/dist/tool/code-execution.d.ts +0 -17
  90. package/dist/tool/code-execution.d.ts.map +0 -1
  91. package/dist/tool/code-execution.js +0 -25
  92. package/dist/tool/enterprise-web-search.d.ts +0 -2
  93. package/dist/tool/enterprise-web-search.d.ts.map +0 -1
  94. package/dist/tool/enterprise-web-search.js +0 -8
  95. package/dist/tool/file-search.d.ts +0 -16
  96. package/dist/tool/file-search.d.ts.map +0 -1
  97. package/dist/tool/file-search.js +0 -33
  98. package/dist/tool/google-maps.d.ts +0 -2
  99. package/dist/tool/google-maps.d.ts.map +0 -1
  100. package/dist/tool/google-maps.js +0 -9
  101. package/dist/tool/google-search.d.ts +0 -14
  102. package/dist/tool/google-search.d.ts.map +0 -1
  103. package/dist/tool/google-search.js +0 -15
  104. package/dist/tool/url-context.d.ts +0 -2
  105. package/dist/tool/url-context.d.ts.map +0 -1
  106. package/dist/tool/url-context.js +0 -7
  107. package/dist/tool/vertex-rag-store.d.ts +0 -16
  108. package/dist/tool/vertex-rag-store.d.ts.map +0 -1
  109. package/dist/tool/vertex-rag-store.js +0 -17
  110. package/dist/version.d.ts +0 -2
  111. package/dist/version.d.ts.map +0 -1
  112. package/dist/version.js +0 -3
@@ -1,234 +0,0 @@
1
- import { describe, it, expect, beforeEach, vi } from 'vitest';
2
- import { createGoogleGenerativeAI } from './google-provider';
3
- import { GoogleGenerativeAILanguageModel } from './google-generative-ai-language-model';
4
- import { GoogleGenerativeAIEmbeddingModel } from './google-generative-ai-embedding-model';
5
- import { GoogleGenerativeAIImageModel } from './google-generative-ai-image-model';
6
- // Mock the imported modules using a partial mock to preserve original exports
7
- vi.mock('@ai-sdk/provider-utils', async (importOriginal) => {
8
- const mod = await importOriginal();
9
- return {
10
- ...mod,
11
- loadApiKey: vi.fn().mockImplementation(({ apiKey }) => apiKey),
12
- generateId: vi.fn().mockReturnValue('mock-id'),
13
- withoutTrailingSlash: vi.fn().mockImplementation(url => url),
14
- };
15
- });
16
- vi.mock('./google-generative-ai-language-model', () => ({
17
- GoogleGenerativeAILanguageModel: vi.fn(),
18
- }));
19
- vi.mock('./google-generative-ai-embedding-model', () => ({
20
- GoogleGenerativeAIEmbeddingModel: vi.fn(),
21
- }));
22
- vi.mock('./google-generative-ai-image-model', () => ({
23
- GoogleGenerativeAIImageModel: vi.fn(),
24
- }));
25
- vi.mock('./version', () => ({
26
- VERSION: '0.0.0-test',
27
- }));
28
- describe('google-provider', () => {
29
- beforeEach(() => {
30
- vi.clearAllMocks();
31
- });
32
- it('should create a language model with default settings', () => {
33
- const provider = createGoogleGenerativeAI({
34
- apiKey: 'test-api-key',
35
- });
36
- provider('gemini-pro');
37
- expect(GoogleGenerativeAILanguageModel).toHaveBeenCalledWith('gemini-pro', expect.objectContaining({
38
- provider: 'google.generative-ai',
39
- baseURL: 'https://cloudcode-pa.googleapis.com',
40
- headers: expect.any(Function),
41
- generateId: expect.any(Function),
42
- supportedUrls: expect.any(Function),
43
- }));
44
- });
45
- it('should throw an error when using new keyword', () => {
46
- const provider = createGoogleGenerativeAI({ apiKey: 'test-api-key' });
47
- expect(() => new provider('gemini-pro')).toThrow('The Google Generative AI model function cannot be called with the new keyword.');
48
- });
49
- it('should create an embedding model with correct settings', () => {
50
- const provider = createGoogleGenerativeAI({
51
- apiKey: 'test-api-key',
52
- });
53
- provider.textEmbeddingModel('embedding-001');
54
- expect(GoogleGenerativeAIEmbeddingModel).toHaveBeenCalledWith('embedding-001', expect.objectContaining({
55
- provider: 'google.generative-ai',
56
- headers: expect.any(Function),
57
- baseURL: 'https://cloudcode-pa.googleapis.com',
58
- }));
59
- });
60
- it('should pass custom headers to the model constructor', () => {
61
- const customHeaders = { 'Custom-Header': 'custom-value' };
62
- const provider = createGoogleGenerativeAI({
63
- apiKey: 'test-api-key',
64
- headers: customHeaders,
65
- });
66
- provider('gemini-pro');
67
- expect(GoogleGenerativeAILanguageModel).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
68
- headers: expect.any(Function),
69
- }));
70
- const options = GoogleGenerativeAILanguageModel.mock.calls[0][1];
71
- const headers = options.headers();
72
- expect(headers).toEqual({
73
- authorization: 'Bearer test-api-key',
74
- 'custom-header': 'custom-value',
75
- 'user-agent': 'ai-sdk/google-cloudassist/0.0.0-test',
76
- });
77
- });
78
- it('should pass custom generateId function to the model constructor', () => {
79
- const customGenerateId = () => 'custom-id';
80
- const provider = createGoogleGenerativeAI({
81
- apiKey: 'test-api-key',
82
- generateId: customGenerateId,
83
- });
84
- provider('gemini-pro');
85
- expect(GoogleGenerativeAILanguageModel).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
86
- generateId: customGenerateId,
87
- }));
88
- });
89
- it('should use chat method to create a model', () => {
90
- const provider = createGoogleGenerativeAI({
91
- apiKey: 'test-api-key',
92
- });
93
- provider.chat('gemini-pro');
94
- expect(GoogleGenerativeAILanguageModel).toHaveBeenCalledWith('gemini-pro', expect.any(Object));
95
- });
96
- it('should use custom baseURL when provided', () => {
97
- const customBaseURL = 'https://custom-endpoint.example.com';
98
- const provider = createGoogleGenerativeAI({
99
- apiKey: 'test-api-key',
100
- baseURL: customBaseURL,
101
- });
102
- provider('gemini-pro');
103
- expect(GoogleGenerativeAILanguageModel).toHaveBeenCalledWith('gemini-pro', expect.objectContaining({
104
- baseURL: customBaseURL,
105
- }));
106
- });
107
- it('should create an image model with default settings', () => {
108
- const provider = createGoogleGenerativeAI({
109
- apiKey: 'test-api-key',
110
- });
111
- provider.image('imagen-3.0-generate-002');
112
- expect(GoogleGenerativeAIImageModel).toHaveBeenCalledWith('imagen-3.0-generate-002', {}, expect.objectContaining({
113
- provider: 'google.generative-ai',
114
- headers: expect.any(Function),
115
- baseURL: 'https://cloudcode-pa.googleapis.com',
116
- }));
117
- });
118
- it('should create an image model with custom maxImagesPerCall', () => {
119
- const provider = createGoogleGenerativeAI({
120
- apiKey: 'test-api-key',
121
- });
122
- const imageSettings = {
123
- maxImagesPerCall: 3,
124
- };
125
- provider.image('imagen-3.0-generate-002', imageSettings);
126
- expect(GoogleGenerativeAIImageModel).toHaveBeenCalledWith('imagen-3.0-generate-002', imageSettings, expect.objectContaining({
127
- provider: 'google.generative-ai',
128
- headers: expect.any(Function),
129
- baseURL: 'https://cloudcode-pa.googleapis.com',
130
- }));
131
- });
132
- it('should support deprecated methods', () => {
133
- const provider = createGoogleGenerativeAI({
134
- apiKey: 'test-api-key',
135
- });
136
- provider.generativeAI('gemini-pro');
137
- provider.embedding('embedding-001');
138
- provider.textEmbedding('embedding-001');
139
- expect(GoogleGenerativeAILanguageModel).toHaveBeenCalledTimes(1);
140
- expect(GoogleGenerativeAIEmbeddingModel).toHaveBeenCalledTimes(2);
141
- });
142
- it('should include YouTube URLs in supportedUrls', () => {
143
- const provider = createGoogleGenerativeAI({
144
- apiKey: 'test-api-key',
145
- });
146
- provider('gemini-pro');
147
- const call = vi.mocked(GoogleGenerativeAILanguageModel).mock.calls[0];
148
- const supportedUrlsFunction = call[1].supportedUrls;
149
- expect(supportedUrlsFunction).toBeDefined();
150
- const supportedUrls = supportedUrlsFunction();
151
- const patterns = supportedUrls['*'];
152
- expect(patterns).toBeDefined();
153
- expect(Array.isArray(patterns)).toBe(true);
154
- const testResults = {
155
- supportedUrls: [
156
- 'https://cloudcode-pa.googleapis.com/files/test123',
157
- 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
158
- 'https://youtube.com/watch?v=dQw4w9WgXcQ',
159
- 'https://youtu.be/dQw4w9WgXcQ',
160
- ].map(url => ({
161
- url,
162
- isSupported: patterns.some((pattern) => pattern.test(url)),
163
- })),
164
- unsupportedUrls: [
165
- 'https://example.com',
166
- 'https://vimeo.com/123456789',
167
- 'https://youtube.com/channel/UCdQw4w9WgXcQ',
168
- ].map(url => ({
169
- url,
170
- isSupported: patterns.some((pattern) => pattern.test(url)),
171
- })),
172
- };
173
- expect(testResults).toMatchInlineSnapshot(`
174
- {
175
- "supportedUrls": [
176
- {
177
- "isSupported": true,
178
- "url": "https://cloudcode-pa.googleapis.com/files/test123",
179
- },
180
- {
181
- "isSupported": true,
182
- "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
183
- },
184
- {
185
- "isSupported": true,
186
- "url": "https://youtube.com/watch?v=dQw4w9WgXcQ",
187
- },
188
- {
189
- "isSupported": true,
190
- "url": "https://youtu.be/dQw4w9WgXcQ",
191
- },
192
- ],
193
- "unsupportedUrls": [
194
- {
195
- "isSupported": false,
196
- "url": "https://example.com",
197
- },
198
- {
199
- "isSupported": false,
200
- "url": "https://vimeo.com/123456789",
201
- },
202
- {
203
- "isSupported": false,
204
- "url": "https://youtube.com/channel/UCdQw4w9WgXcQ",
205
- },
206
- ],
207
- }
208
- `);
209
- });
210
- });
211
- describe('google provider - custom provider name', () => {
212
- beforeEach(() => {
213
- vi.clearAllMocks();
214
- });
215
- it('should use custom provider name when specified', () => {
216
- const provider = createGoogleGenerativeAI({
217
- name: 'my-gemini-proxy',
218
- apiKey: 'test-api-key',
219
- });
220
- provider('gemini-pro');
221
- expect(GoogleGenerativeAILanguageModel).toHaveBeenCalledWith('gemini-pro', expect.objectContaining({
222
- provider: 'my-gemini-proxy',
223
- }));
224
- });
225
- it('should default to google.generative-ai when name not specified', () => {
226
- const provider = createGoogleGenerativeAI({
227
- apiKey: 'test-api-key',
228
- });
229
- provider('gemini-pro');
230
- expect(GoogleGenerativeAILanguageModel).toHaveBeenCalledWith('gemini-pro', expect.objectContaining({
231
- provider: 'google.generative-ai',
232
- }));
233
- });
234
- });
@@ -1,2 +0,0 @@
1
- export declare function isSupportedFileUrl(url: URL): boolean;
2
- //# sourceMappingURL=google-supported-file-url.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-supported-file-url.d.ts","sourceRoot":"","sources":["../src/google-supported-file-url.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAmBpD"}
@@ -1,13 +0,0 @@
1
- export function isSupportedFileUrl(url) {
2
- const urlString = url.toString();
3
- // Google Generative Language files API
4
- if (urlString.startsWith('https://generativelanguage.googleapis.com/v1beta/files/')) {
5
- return true;
6
- }
7
- // YouTube URLs (public or unlisted videos)
8
- const youtubeRegexes = [
9
- /^https:\/\/(?:www\.)?youtube\.com\/watch\?v=[\w-]+(?:&[\w=&.-]*)?$/,
10
- /^https:\/\/youtu\.be\/[\w-]+(?:\?[\w=&.-]*)?$/,
11
- ];
12
- return youtubeRegexes.some(regex => regex.test(urlString));
13
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=google-supported-file-url.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-supported-file-url.test.d.ts","sourceRoot":"","sources":["../src/google-supported-file-url.test.ts"],"names":[],"mappings":""}
@@ -1,45 +0,0 @@
1
- import { isSupportedFileUrl } from './google-supported-file-url';
2
- import { it, expect } from 'vitest';
3
- it('should return true for valid Google generative language file URLs', () => {
4
- const validUrl = new URL('https://generativelanguage.googleapis.com/v1beta/files/00000000-00000000-00000000-00000000');
5
- expect(isSupportedFileUrl(validUrl)).toBe(true);
6
- const simpleValidUrl = new URL('https://generativelanguage.googleapis.com/v1beta/files/test123');
7
- expect(isSupportedFileUrl(simpleValidUrl)).toBe(true);
8
- });
9
- it('should return true for valid YouTube URLs', () => {
10
- const validYouTubeUrls = [
11
- new URL('https://www.youtube.com/watch?v=dQw4w9WgXcQ'),
12
- new URL('https://youtube.com/watch?v=dQw4w9WgXcQ'),
13
- new URL('https://youtu.be/dQw4w9WgXcQ'),
14
- new URL('https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtu.be'),
15
- new URL('https://youtu.be/dQw4w9WgXcQ?t=42'),
16
- ];
17
- validYouTubeUrls.forEach(url => {
18
- expect(isSupportedFileUrl(url)).toBe(true);
19
- });
20
- });
21
- it('should return false for invalid YouTube URLs', () => {
22
- const invalidYouTubeUrls = [
23
- new URL('https://youtube.com/channel/UCdQw4w9WgXcQ'),
24
- new URL('https://youtube.com/playlist?list=PLdQw4w9WgXcQ'),
25
- new URL('https://m.youtube.com/watch?v=dQw4w9WgXcQ'),
26
- new URL('http://youtube.com/watch?v=dQw4w9WgXcQ'),
27
- new URL('https://vimeo.com/123456789'),
28
- ];
29
- invalidYouTubeUrls.forEach(url => {
30
- expect(isSupportedFileUrl(url)).toBe(false);
31
- });
32
- });
33
- it('should return false for non-Google generative language file URLs', () => {
34
- const testCases = [
35
- new URL('https://example.com'),
36
- new URL('https://example.com/foo/bar'),
37
- new URL('https://generativelanguage.googleapis.com'),
38
- new URL('https://generativelanguage.googleapis.com/v1/other'),
39
- new URL('http://generativelanguage.googleapis.com/v1beta/files/test'),
40
- new URL('https://api.googleapis.com/v1beta/files/test'),
41
- ];
42
- testCases.forEach(url => {
43
- expect(isSupportedFileUrl(url)).toBe(false);
44
- });
45
- });
@@ -1,76 +0,0 @@
1
- export declare const googleTools: {
2
- /**
3
- * Creates a Google search tool that gives Google direct access to real-time web content.
4
- * Must have name "google_search".
5
- */
6
- googleSearch: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {
7
- mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
8
- dynamicThreshold?: number;
9
- }>;
10
- /**
11
- * Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
12
- * Designed for highly-regulated industries (finance, healthcare, public sector).
13
- * Does not log customer data and supports VPC service controls.
14
- * Must have name "enterprise_web_search".
15
- *
16
- * @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
17
- *
18
- * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
19
- */
20
- enterpriseWebSearch: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {}>;
21
- /**
22
- * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
23
- * Must have name "google_maps".
24
- *
25
- * @see https://ai.google.dev/gemini-api/docs/maps-grounding
26
- * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
27
- */
28
- googleMaps: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {}>;
29
- /**
30
- * Creates a URL context tool that gives Google direct access to real-time web content.
31
- * Must have name "url_context".
32
- */
33
- urlContext: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {}>;
34
- /**
35
- * Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
36
- * Must have name "file_search".
37
- *
38
- * @param fileSearchStoreNames - Fully-qualified File Search store resource names.
39
- * @param metadataFilter - Optional filter expression to restrict the files that can be retrieved.
40
- * @param topK - Optional result limit for the number of chunks returned from File Search.
41
- *
42
- * @see https://ai.google.dev/gemini-api/docs/file-search
43
- */
44
- fileSearch: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {
45
- [x: string]: unknown;
46
- fileSearchStoreNames: string[];
47
- topK?: number | undefined;
48
- metadataFilter?: string | undefined;
49
- }>;
50
- /**
51
- * A tool that enables the model to generate and run Python code.
52
- * Must have name "code_execution".
53
- *
54
- * @note Ensure the selected model supports Code Execution.
55
- * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
56
- *
57
- * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
58
- * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
59
- */
60
- codeExecution: import("@ai-sdk/provider-utils").ProviderDefinedToolFactoryWithOutputSchema<{
61
- language: string;
62
- code: string;
63
- }, {
64
- outcome: string;
65
- output: string;
66
- }, {}>;
67
- /**
68
- * Creates a Vertex RAG Store tool that enables the model to perform RAG searches against a Vertex RAG Store.
69
- * Must have name "vertex_rag_store".
70
- */
71
- vertexRagStore: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {
72
- ragCorpus: string;
73
- topK?: number;
74
- }>;
75
- };
76
- //# sourceMappingURL=google-tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-tools.d.ts","sourceRoot":"","sources":["../src/google-tools.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW;IACtB;;;OAGG;;;;;IAGH;;;;;;;;;OASG;;IAGH;;;;;;OAMG;;IAGH;;;OAGG;;IAGH;;;;;;;;;OASG;;;;;;;IAEH;;;;;;;;;OASG;;;;;;;;IAGH;;;OAGG;;;;;CAEJ,CAAC"}
@@ -1,65 +0,0 @@
1
- import { codeExecution } from './tool/code-execution';
2
- import { enterpriseWebSearch } from './tool/enterprise-web-search';
3
- import { fileSearch } from './tool/file-search';
4
- import { googleMaps } from './tool/google-maps';
5
- import { googleSearch } from './tool/google-search';
6
- import { urlContext } from './tool/url-context';
7
- import { vertexRagStore } from './tool/vertex-rag-store';
8
- export const googleTools = {
9
- /**
10
- * Creates a Google search tool that gives Google direct access to real-time web content.
11
- * Must have name "google_search".
12
- */
13
- googleSearch,
14
- /**
15
- * Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
16
- * Designed for highly-regulated industries (finance, healthcare, public sector).
17
- * Does not log customer data and supports VPC service controls.
18
- * Must have name "enterprise_web_search".
19
- *
20
- * @note Only available on Vertex AI. Requires Gemini 2.0 or newer.
21
- *
22
- * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
23
- */
24
- enterpriseWebSearch,
25
- /**
26
- * Creates a Google Maps grounding tool that gives the model access to Google Maps data.
27
- * Must have name "google_maps".
28
- *
29
- * @see https://ai.google.dev/gemini-api/docs/maps-grounding
30
- * @see https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
31
- */
32
- googleMaps,
33
- /**
34
- * Creates a URL context tool that gives Google direct access to real-time web content.
35
- * Must have name "url_context".
36
- */
37
- urlContext,
38
- /**
39
- * Enables Retrieval Augmented Generation (RAG) via the Gemini File Search tool.
40
- * Must have name "file_search".
41
- *
42
- * @param fileSearchStoreNames - Fully-qualified File Search store resource names.
43
- * @param metadataFilter - Optional filter expression to restrict the files that can be retrieved.
44
- * @param topK - Optional result limit for the number of chunks returned from File Search.
45
- *
46
- * @see https://ai.google.dev/gemini-api/docs/file-search
47
- */
48
- fileSearch,
49
- /**
50
- * A tool that enables the model to generate and run Python code.
51
- * Must have name "code_execution".
52
- *
53
- * @note Ensure the selected model supports Code Execution.
54
- * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
55
- *
56
- * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
57
- * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
58
- */
59
- codeExecution,
60
- /**
61
- * Creates a Vertex RAG Store tool that enables the model to perform RAG searches against a Vertex RAG Store.
62
- * Must have name "vertex_rag_store".
63
- */
64
- vertexRagStore,
65
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACxF,YAAY,EAAE,kCAAkC,EAAE,MAAM,+BAA+B,CAAC;AACxF,YAAY,EAAE,sCAAsC,EAAE,MAAM,oCAAoC,CAAC;AACjG,YAAY,EAAE,0CAA0C,EAAE,MAAM,0CAA0C,CAAC;AAC3G,OAAO,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACrE,YAAY,EACV,0BAA0B,EAC1B,kCAAkC,GACnC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,6 +0,0 @@
1
- import { LanguageModelV2FinishReason } from '@ai-sdk/provider';
2
- export declare function mapGoogleGenerativeAIFinishReason({ finishReason, hasToolCalls, }: {
3
- finishReason: string | null | undefined;
4
- hasToolCalls: boolean;
5
- }): LanguageModelV2FinishReason;
6
- //# sourceMappingURL=map-google-generative-ai-finish-reason.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"map-google-generative-ai-finish-reason.d.ts","sourceRoot":"","sources":["../src/map-google-generative-ai-finish-reason.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,wBAAgB,iCAAiC,CAAC,EAChD,YAAY,EACZ,YAAY,GACb,EAAE;IACD,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,YAAY,EAAE,OAAO,CAAC;CACvB,GAAG,2BAA2B,CAqB9B"}
@@ -1,22 +0,0 @@
1
- export function mapGoogleGenerativeAIFinishReason({ finishReason, hasToolCalls, }) {
2
- switch (finishReason) {
3
- case 'STOP':
4
- return hasToolCalls ? 'tool-calls' : 'stop';
5
- case 'MAX_TOKENS':
6
- return 'length';
7
- case 'IMAGE_SAFETY':
8
- case 'RECITATION':
9
- case 'SAFETY':
10
- case 'BLOCKLIST':
11
- case 'PROHIBITED_CONTENT':
12
- case 'SPII':
13
- return 'content-filter';
14
- case 'FINISH_REASON_UNSPECIFIED':
15
- case 'OTHER':
16
- return 'other';
17
- case 'MALFORMED_FUNCTION_CALL':
18
- return 'error';
19
- default:
20
- return 'unknown';
21
- }
22
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * A tool that enables the model to generate and run Python code.
3
- *
4
- * @note Ensure the selected model supports Code Execution.
5
- * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
6
- *
7
- * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
8
- * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
9
- */
10
- export declare const codeExecution: import("@ai-sdk/provider-utils").ProviderDefinedToolFactoryWithOutputSchema<{
11
- language: string;
12
- code: string;
13
- }, {
14
- outcome: string;
15
- output: string;
16
- }, {}>;
17
- //# sourceMappingURL=code-execution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-execution.d.ts","sourceRoot":"","sources":["../../src/tool/code-execution.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;cAEZ,MAAM;UACV,MAAM;;aAGH,MAAM;YACP,MAAM;MAgBhB,CAAC"}
@@ -1,25 +0,0 @@
1
- import { createProviderDefinedToolFactoryWithOutputSchema } from '@ai-sdk/provider-utils';
2
- import { z } from 'zod/v4';
3
- /**
4
- * A tool that enables the model to generate and run Python code.
5
- *
6
- * @note Ensure the selected model supports Code Execution.
7
- * Multi-tool usage with the code execution tool is typically compatible with Gemini >=2 models.
8
- *
9
- * @see https://ai.google.dev/gemini-api/docs/code-execution (Google AI)
10
- * @see https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/code-execution-api (Vertex AI)
11
- */
12
- export const codeExecution = createProviderDefinedToolFactoryWithOutputSchema({
13
- id: 'google.code_execution',
14
- name: 'code_execution',
15
- inputSchema: z.object({
16
- language: z.string().describe('The programming language of the code.'),
17
- code: z.string().describe('The code to be executed.'),
18
- }),
19
- outputSchema: z.object({
20
- outcome: z
21
- .string()
22
- .describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
23
- output: z.string().describe('The output from the code execution.'),
24
- }),
25
- });
@@ -1,2 +0,0 @@
1
- export declare const enterpriseWebSearch: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {}>;
2
- //# sourceMappingURL=enterprise-web-search.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enterprise-web-search.d.ts","sourceRoot":"","sources":["../../src/tool/enterprise-web-search.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,qEAS9B,CAAC"}
@@ -1,8 +0,0 @@
1
- import { createProviderDefinedToolFactory, lazySchema, zodSchema, } from '@ai-sdk/provider-utils';
2
- import { z } from 'zod/v4';
3
- // https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
4
- export const enterpriseWebSearch = createProviderDefinedToolFactory({
5
- id: 'google.enterprise_web_search',
6
- name: 'enterprise_web_search',
7
- inputSchema: lazySchema(() => zodSchema(z.object({}))),
8
- });
@@ -1,16 +0,0 @@
1
- import { z } from 'zod/v4';
2
- /** Tool to retrieve knowledge from the File Search Stores. */
3
- declare const fileSearchArgsBaseSchema: z.ZodObject<{
4
- fileSearchStoreNames: z.ZodArray<z.ZodString>;
5
- topK: z.ZodOptional<z.ZodNumber>;
6
- metadataFilter: z.ZodOptional<z.ZodString>;
7
- }, z.core.$loose>;
8
- export type GoogleFileSearchToolArgs = z.infer<typeof fileSearchArgsBaseSchema>;
9
- export declare const fileSearch: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {
10
- [x: string]: unknown;
11
- fileSearchStoreNames: string[];
12
- topK?: number | undefined;
13
- metadataFilter?: string | undefined;
14
- }>;
15
- export {};
16
- //# sourceMappingURL=file-search.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-search.d.ts","sourceRoot":"","sources":["../../src/tool/file-search.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,8DAA8D;AAC9D,QAAA,MAAM,wBAAwB;;;;iBA4Bd,CAAC;AAEjB,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAMhF,eAAO,MAAM,UAAU;;;;;EAOrB,CAAC"}
@@ -1,33 +0,0 @@
1
- import { createProviderDefinedToolFactory, lazySchema, zodSchema, } from '@ai-sdk/provider-utils';
2
- import { z } from 'zod/v4';
3
- /** Tool to retrieve knowledge from the File Search Stores. */
4
- const fileSearchArgsBaseSchema = z
5
- .object({
6
- /** The names of the file_search_stores to retrieve from.
7
- * Example: `fileSearchStores/my-file-search-store-123`
8
- */
9
- fileSearchStoreNames: z
10
- .array(z.string())
11
- .describe('The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`'),
12
- /** The number of file search retrieval chunks to retrieve. */
13
- topK: z
14
- .number()
15
- .int()
16
- .positive()
17
- .describe('The number of file search retrieval chunks to retrieve.')
18
- .optional(),
19
- /** Metadata filter to apply to the file search retrieval documents.
20
- * See https://google.aip.dev/160 for the syntax of the filter expression.
21
- */
22
- metadataFilter: z
23
- .string()
24
- .describe('Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression.')
25
- .optional(),
26
- })
27
- .passthrough();
28
- const fileSearchArgsSchema = lazySchema(() => zodSchema(fileSearchArgsBaseSchema));
29
- export const fileSearch = createProviderDefinedToolFactory({
30
- id: 'google.file_search',
31
- name: 'file_search',
32
- inputSchema: fileSearchArgsSchema,
33
- });
@@ -1,2 +0,0 @@
1
- export declare const googleMaps: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {}>;
2
- //# sourceMappingURL=google-maps.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"google-maps.d.ts","sourceRoot":"","sources":["../../src/tool/google-maps.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,qEAIrB,CAAC"}
@@ -1,9 +0,0 @@
1
- import { createProviderDefinedToolFactory, lazySchema, zodSchema, } from '@ai-sdk/provider-utils';
2
- import { z } from 'zod/v4';
3
- // https://ai.google.dev/gemini-api/docs/maps-grounding
4
- // https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/grounding-with-google-maps
5
- export const googleMaps = createProviderDefinedToolFactory({
6
- id: 'google.google_maps',
7
- name: 'google_maps',
8
- inputSchema: lazySchema(() => zodSchema(z.object({}))),
9
- });
@@ -1,14 +0,0 @@
1
- export declare const googleSearch: import("@ai-sdk/provider-utils").ProviderDefinedToolFactory<{}, {
2
- /**
3
- * The mode of the predictor to be used in dynamic retrieval. The following modes are supported:
4
- * - MODE_DYNAMIC: Run retrieval only when system decides it is necessary
5
- * - MODE_UNSPECIFIED: Always trigger retrieval
6
- * @default MODE_UNSPECIFIED
7
- */
8
- mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
9
- /**
10
- * The threshold to be used in dynamic retrieval (if not set, a system default value is used).
11
- */
12
- dynamicThreshold?: number;
13
- }>;
14
- //# sourceMappingURL=google-search.d.ts.map