@ai-sdk/google-vertex 4.0.233 → 4.0.234
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 +16 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/anthropic/edge/index.mjs +1 -1
- package/dist/edge/index.d.mts +30 -2
- package/dist/edge/index.d.ts +30 -2
- package/dist/edge/index.js +12 -3
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/index.mjs +12 -3
- package/dist/edge/index.mjs.map +1 -1
- package/dist/index.d.mts +30 -2
- package/dist/index.d.ts +30 -2
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -3
- package/dist/index.mjs.map +1 -1
- package/dist/maas/edge/index.js +1 -1
- package/dist/maas/edge/index.mjs +1 -1
- package/dist/xai/edge/index.js +1 -1
- package/dist/xai/edge/index.mjs +1 -1
- package/docs/16-google-vertex.mdx +36 -3
- package/package.json +5 -5
- package/src/google-vertex-provider.ts +46 -2
|
@@ -144,16 +144,27 @@ You can use the following optional settings to customize the provider instance:
|
|
|
144
144
|
|
|
145
145
|
- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_
|
|
146
146
|
|
|
147
|
-
Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
|
|
147
|
+
Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation for Vertex API requests.
|
|
148
148
|
Defaults to the global `fetch` function.
|
|
149
149
|
You can use it as a middleware to intercept requests,
|
|
150
150
|
or to provide a custom fetch implementation for e.g. testing.
|
|
151
|
+
This option is not used to download tool result files; see `toolResultDownloads`.
|
|
151
152
|
|
|
152
153
|
- **baseURL** _string_
|
|
153
154
|
|
|
154
155
|
Optional. Base URL for the Google Vertex API calls e.g. to use proxy servers. By default, it is constructed using the location and project:
|
|
155
156
|
`https://${location}-aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/google`
|
|
156
157
|
|
|
158
|
+
- **toolResultDownloads** _{ maxBytes?: number, fetch?: FetchFunction }_
|
|
159
|
+
|
|
160
|
+
Configuration for downloading tool result files that Vertex cannot reference directly in function responses.
|
|
161
|
+
|
|
162
|
+
- **maxBytes** _number_
|
|
163
|
+
Maximum size of each downloaded tool result file in bytes. Defaults to 7 MiB.
|
|
164
|
+
|
|
165
|
+
- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_
|
|
166
|
+
Transport for tool result downloads. Defaults to a validated transport that pins DNS results on Node.js. Only provide a transport that performs equivalent connect-time DNS validation for untrusted URLs, such as a guarded fetch on Bun or Deno.
|
|
167
|
+
|
|
157
168
|
<a id="google-vertex-edge-runtime"></a>
|
|
158
169
|
#### Edge Runtime
|
|
159
170
|
|
|
@@ -233,10 +244,21 @@ You can use the following optional settings to customize the provider instance:
|
|
|
233
244
|
|
|
234
245
|
- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_
|
|
235
246
|
|
|
236
|
-
Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
|
|
247
|
+
Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation for Vertex API requests.
|
|
237
248
|
Defaults to the global `fetch` function.
|
|
238
249
|
You can use it as a middleware to intercept requests,
|
|
239
250
|
or to provide a custom fetch implementation for e.g. testing.
|
|
251
|
+
This option is not used to download tool result files; see `toolResultDownloads`.
|
|
252
|
+
|
|
253
|
+
- **toolResultDownloads** _{ maxBytes?: number, fetch?: FetchFunction }_
|
|
254
|
+
|
|
255
|
+
Configuration for downloading tool result files that Vertex cannot reference directly in function responses.
|
|
256
|
+
|
|
257
|
+
- **maxBytes** _number_
|
|
258
|
+
Maximum size of each downloaded tool result file in bytes. Defaults to 7 MiB.
|
|
259
|
+
|
|
260
|
+
- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_
|
|
261
|
+
Transport for tool result downloads. Defaults to a validated transport that pins DNS results on Node.js. Only provide a transport that performs equivalent connect-time DNS validation for untrusted URLs, such as a guarded fetch on Bun or Deno.
|
|
240
262
|
|
|
241
263
|
#### Express Mode
|
|
242
264
|
|
|
@@ -764,7 +786,18 @@ tool-result forwarding is not supported for older Gemini models, missing or
|
|
|
764
786
|
wildcard MIME types, or MIME types outside the list above.
|
|
765
787
|
|
|
766
788
|
HTTP(S) tool-result files are downloaded and sent as inline data, including when
|
|
767
|
-
the file part specifies a `mediaType`.
|
|
789
|
+
the file part specifies a `mediaType`. Downloads use a validated transport that
|
|
790
|
+
resolves every hostname through a validating lookup hook and pins the connection
|
|
791
|
+
to the resolved address on Node.js, independent of the provider `fetch` option.
|
|
792
|
+
Each file is limited to `toolResultDownloads.maxBytes` (7 MiB by default), and the
|
|
793
|
+
Vertex API key is never sent to those hosts.
|
|
794
|
+
|
|
795
|
+
On Node.js, leave `toolResultDownloads.fetch` unset so this protection stays in
|
|
796
|
+
effect. On other server runtimes (for example Bun or Deno) the default download
|
|
797
|
+
transport is the runtime's global fetch, which does not pin DNS results: pass a
|
|
798
|
+
guarded fetch via `toolResultDownloads.fetch` when tool result URLs are untrusted,
|
|
799
|
+
or constrain egress at the network layer. Direct `gs://` references are fetched by
|
|
800
|
+
Vertex instead.
|
|
768
801
|
|
|
769
802
|
### Cached Content
|
|
770
803
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google-vertex",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.234",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"google-auth-library": "^10.5.0",
|
|
75
|
-
"@ai-sdk/anthropic": "3.0.
|
|
76
|
-
"@ai-sdk/google": "3.0.
|
|
77
|
-
"@ai-sdk/openai-compatible": "2.0.
|
|
75
|
+
"@ai-sdk/anthropic": "3.0.143",
|
|
76
|
+
"@ai-sdk/google": "3.0.147",
|
|
77
|
+
"@ai-sdk/openai-compatible": "2.0.94",
|
|
78
78
|
"@ai-sdk/provider": "3.0.19",
|
|
79
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
79
|
+
"@ai-sdk/provider-utils": "4.0.67"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/node": "20.17.24",
|
|
@@ -40,6 +40,10 @@ import type { GoogleVertexVideoModelId } from './google-vertex-video-settings';
|
|
|
40
40
|
const EXPRESS_MODE_BASE_URL =
|
|
41
41
|
'https://aiplatform.googleapis.com/v1/publishers/google';
|
|
42
42
|
|
|
43
|
+
// Tool result files are sent inline in the request, so the limit also keeps the
|
|
44
|
+
// generated request body a reasonable size. Mirrors the upstream default.
|
|
45
|
+
const DEFAULT_TOOL_RESULT_DOWNLOAD_MAX_BYTES = 7 * 1024 * 1024;
|
|
46
|
+
|
|
43
47
|
// set `x-goog-api-key` header to API key for express mode
|
|
44
48
|
function createExpressModeFetch(
|
|
45
49
|
apiKey: string,
|
|
@@ -150,8 +154,12 @@ export interface GoogleVertexProviderSettings {
|
|
|
150
154
|
headers?: Resolvable<Record<string, string | undefined>>;
|
|
151
155
|
|
|
152
156
|
/**
|
|
153
|
-
* Custom fetch implementation. You can use it as a
|
|
154
|
-
* or to provide a custom fetch
|
|
157
|
+
* Custom fetch implementation for Vertex API requests. You can use it as a
|
|
158
|
+
* middleware to intercept requests, or to provide a custom fetch
|
|
159
|
+
* implementation for e.g. testing.
|
|
160
|
+
*
|
|
161
|
+
* It is not used to download tool result files; those downloads use the
|
|
162
|
+
* validated default transport unless `toolResultDownloads.fetch` is set.
|
|
155
163
|
*/
|
|
156
164
|
fetch?: FetchFunction;
|
|
157
165
|
|
|
@@ -162,6 +170,32 @@ export interface GoogleVertexProviderSettings {
|
|
|
162
170
|
* Base URL for the Google Vertex API calls.
|
|
163
171
|
*/
|
|
164
172
|
baseURL?: string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Configuration for downloading tool result files whose URLs cannot be
|
|
176
|
+
* referenced in Vertex function responses.
|
|
177
|
+
*/
|
|
178
|
+
toolResultDownloads?: {
|
|
179
|
+
/**
|
|
180
|
+
* Maximum number of bytes per downloaded tool result file.
|
|
181
|
+
* Defaults to 7 MiB.
|
|
182
|
+
*/
|
|
183
|
+
maxBytes?: number;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Transport used to download tool result files.
|
|
187
|
+
*
|
|
188
|
+
* Downloads default to a validated transport that resolves every hostname
|
|
189
|
+
* through a validating lookup hook and pins the connection to the resolved
|
|
190
|
+
* address on Node.js. Pass a fetch here only if it provides equivalent
|
|
191
|
+
* connect-time DNS validation for the URLs you download, e.g. a guarded
|
|
192
|
+
* fetch on Bun or Deno.
|
|
193
|
+
*
|
|
194
|
+
* The `fetch` option is not used for these downloads, and the Vertex API key
|
|
195
|
+
* is never attached to them.
|
|
196
|
+
*/
|
|
197
|
+
fetch?: FetchFunction;
|
|
198
|
+
};
|
|
165
199
|
}
|
|
166
200
|
|
|
167
201
|
/**
|
|
@@ -251,6 +285,16 @@ export function createVertex(
|
|
|
251
285
|
/^gs:\/\/.*$/,
|
|
252
286
|
],
|
|
253
287
|
}),
|
|
288
|
+
downloadToolResultFiles: {
|
|
289
|
+
maxBytes:
|
|
290
|
+
options.toolResultDownloads?.maxBytes ??
|
|
291
|
+
DEFAULT_TOOL_RESULT_DOWNLOAD_MAX_BYTES,
|
|
292
|
+
// Tool result hosts are unrelated to the Vertex API, so this must be an
|
|
293
|
+
// explicit download transport. The provider `fetch` is often a logging
|
|
294
|
+
// or proxy wrapper that would replace the DNS-pinned default transport,
|
|
295
|
+
// and the Express Mode wrapper would leak the API key to those hosts.
|
|
296
|
+
fetch: options.toolResultDownloads?.fetch,
|
|
297
|
+
},
|
|
254
298
|
});
|
|
255
299
|
};
|
|
256
300
|
|