cloudassist-ai-provider 0.0.1

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 (117) hide show
  1. package/CHANGELOG.md +1901 -0
  2. package/README.md +35 -0
  3. package/dist/convert-json-schema-to-openapi-schema.d.ts +6 -0
  4. package/dist/convert-json-schema-to-openapi-schema.d.ts.map +1 -0
  5. package/dist/convert-json-schema-to-openapi-schema.js +108 -0
  6. package/dist/convert-json-schema-to-openapi-schema.test.d.ts +2 -0
  7. package/dist/convert-json-schema-to-openapi-schema.test.d.ts.map +1 -0
  8. package/dist/convert-json-schema-to-openapi-schema.test.js +630 -0
  9. package/dist/convert-to-google-generative-ai-messages.d.ts +7 -0
  10. package/dist/convert-to-google-generative-ai-messages.d.ts.map +1 -0
  11. package/dist/convert-to-google-generative-ai-messages.js +195 -0
  12. package/dist/convert-to-google-generative-ai-messages.test.d.ts +2 -0
  13. package/dist/convert-to-google-generative-ai-messages.test.d.ts.map +1 -0
  14. package/dist/convert-to-google-generative-ai-messages.test.js +456 -0
  15. package/dist/get-model-path.d.ts +2 -0
  16. package/dist/get-model-path.d.ts.map +1 -0
  17. package/dist/get-model-path.js +3 -0
  18. package/dist/get-model-path.test.d.ts +2 -0
  19. package/dist/get-model-path.test.d.ts.map +1 -0
  20. package/dist/get-model-path.test.js +11 -0
  21. package/dist/google-error.d.ts +12 -0
  22. package/dist/google-error.d.ts.map +1 -0
  23. package/dist/google-error.js +13 -0
  24. package/dist/google-generative-ai-embedding-model.d.ts +21 -0
  25. package/dist/google-generative-ai-embedding-model.d.ts.map +1 -0
  26. package/dist/google-generative-ai-embedding-model.js +88 -0
  27. package/dist/google-generative-ai-embedding-model.test.d.ts +2 -0
  28. package/dist/google-generative-ai-embedding-model.test.d.ts.map +1 -0
  29. package/dist/google-generative-ai-embedding-model.test.js +148 -0
  30. package/dist/google-generative-ai-embedding-options.d.ts +8 -0
  31. package/dist/google-generative-ai-embedding-options.d.ts.map +1 -0
  32. package/dist/google-generative-ai-embedding-options.js +33 -0
  33. package/dist/google-generative-ai-image-model.d.ts +31 -0
  34. package/dist/google-generative-ai-image-model.d.ts.map +1 -0
  35. package/dist/google-generative-ai-image-model.js +96 -0
  36. package/dist/google-generative-ai-image-model.test.d.ts +2 -0
  37. package/dist/google-generative-ai-image-model.test.d.ts.map +1 -0
  38. package/dist/google-generative-ai-image-model.test.js +252 -0
  39. package/dist/google-generative-ai-image-settings.d.ts +8 -0
  40. package/dist/google-generative-ai-image-settings.d.ts.map +1 -0
  41. package/dist/google-generative-ai-image-settings.js +1 -0
  42. package/dist/google-generative-ai-language-model.d.ts +183 -0
  43. package/dist/google-generative-ai-language-model.d.ts.map +1 -0
  44. package/dist/google-generative-ai-language-model.js +1001 -0
  45. package/dist/google-generative-ai-language-model.test.d.ts +2 -0
  46. package/dist/google-generative-ai-language-model.test.d.ts.map +1 -0
  47. package/dist/google-generative-ai-language-model.test.js +3463 -0
  48. package/dist/google-generative-ai-options.d.ts +37 -0
  49. package/dist/google-generative-ai-options.d.ts.map +1 -0
  50. package/dist/google-generative-ai-options.js +149 -0
  51. package/dist/google-generative-ai-prompt.d.ts +52 -0
  52. package/dist/google-generative-ai-prompt.d.ts.map +1 -0
  53. package/dist/google-generative-ai-prompt.js +1 -0
  54. package/dist/google-prepare-tools.d.ts +27 -0
  55. package/dist/google-prepare-tools.d.ts.map +1 -0
  56. package/dist/google-prepare-tools.js +219 -0
  57. package/dist/google-prepare-tools.test.d.ts +2 -0
  58. package/dist/google-prepare-tools.test.d.ts.map +1 -0
  59. package/dist/google-prepare-tools.test.js +447 -0
  60. package/dist/google-provider.d.ts +65 -0
  61. package/dist/google-provider.d.ts.map +1 -0
  62. package/dist/google-provider.js +74 -0
  63. package/dist/google-provider.test.d.ts +2 -0
  64. package/dist/google-provider.test.d.ts.map +1 -0
  65. package/dist/google-provider.test.js +234 -0
  66. package/dist/google-supported-file-url.d.ts +2 -0
  67. package/dist/google-supported-file-url.d.ts.map +1 -0
  68. package/dist/google-supported-file-url.js +13 -0
  69. package/dist/google-supported-file-url.test.d.ts +2 -0
  70. package/dist/google-supported-file-url.test.d.ts.map +1 -0
  71. package/dist/google-supported-file-url.test.js +45 -0
  72. package/dist/google-tools.d.ts +76 -0
  73. package/dist/google-tools.d.ts.map +1 -0
  74. package/dist/google-tools.js +65 -0
  75. package/dist/index.d.mts +326 -0
  76. package/dist/index.d.ts +9 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +2 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/index.mjs +2172 -0
  81. package/dist/index.mjs.map +1 -0
  82. package/dist/internal/index.d.mts +262 -0
  83. package/dist/internal/index.d.ts +4 -0
  84. package/dist/internal/index.d.ts.map +1 -0
  85. package/dist/internal/index.js +2 -0
  86. package/dist/internal/index.js.map +1 -0
  87. package/dist/internal/index.mjs +1810 -0
  88. package/dist/internal/index.mjs.map +1 -0
  89. package/dist/map-google-generative-ai-finish-reason.d.ts +6 -0
  90. package/dist/map-google-generative-ai-finish-reason.d.ts.map +1 -0
  91. package/dist/map-google-generative-ai-finish-reason.js +22 -0
  92. package/dist/tool/code-execution.d.ts +17 -0
  93. package/dist/tool/code-execution.d.ts.map +1 -0
  94. package/dist/tool/code-execution.js +25 -0
  95. package/dist/tool/enterprise-web-search.d.ts +2 -0
  96. package/dist/tool/enterprise-web-search.d.ts.map +1 -0
  97. package/dist/tool/enterprise-web-search.js +8 -0
  98. package/dist/tool/file-search.d.ts +16 -0
  99. package/dist/tool/file-search.d.ts.map +1 -0
  100. package/dist/tool/file-search.js +33 -0
  101. package/dist/tool/google-maps.d.ts +2 -0
  102. package/dist/tool/google-maps.d.ts.map +1 -0
  103. package/dist/tool/google-maps.js +9 -0
  104. package/dist/tool/google-search.d.ts +14 -0
  105. package/dist/tool/google-search.d.ts.map +1 -0
  106. package/dist/tool/google-search.js +15 -0
  107. package/dist/tool/url-context.d.ts +2 -0
  108. package/dist/tool/url-context.d.ts.map +1 -0
  109. package/dist/tool/url-context.js +7 -0
  110. package/dist/tool/vertex-rag-store.d.ts +16 -0
  111. package/dist/tool/vertex-rag-store.d.ts.map +1 -0
  112. package/dist/tool/vertex-rag-store.js +17 -0
  113. package/dist/version.d.ts +2 -0
  114. package/dist/version.d.ts.map +1 -0
  115. package/dist/version.js +3 -0
  116. package/internal.d.ts +1 -0
  117. package/package.json +73 -0
@@ -0,0 +1,234 @@
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
+ });
@@ -0,0 +1,2 @@
1
+ export declare function isSupportedFileUrl(url: URL): boolean;
2
+ //# sourceMappingURL=google-supported-file-url.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,13 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=google-supported-file-url.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-supported-file-url.test.d.ts","sourceRoot":"","sources":["../src/google-supported-file-url.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,45 @@
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
+ });
@@ -0,0 +1,76 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,65 @@
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
+ };