@ai-sdk/google-vertex 5.0.98 → 5.0.100
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 +28 -0
- package/dist/anthropic/edge/index.d.ts +84 -80
- package/dist/anthropic/edge/index.d.ts.map +1 -0
- package/dist/anthropic/edge/index.js +238 -272
- package/dist/anthropic/edge/index.js.map +1 -1
- package/dist/anthropic/index.d.ts +69 -66
- package/dist/anthropic/index.d.ts.map +1 -0
- package/dist/anthropic/index.js +172 -177
- package/dist/anthropic/index.js.map +1 -1
- package/dist/edge/index.d.ts +206 -194
- package/dist/edge/index.d.ts.map +1 -0
- package/dist/edge/index.js +1428 -1846
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +265 -252
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1369 -1761
- package/dist/index.js.map +1 -1
- package/dist/maas/edge/index.d.ts +62 -59
- package/dist/maas/edge/index.d.ts.map +1 -0
- package/dist/maas/edge/index.js +174 -196
- package/dist/maas/edge/index.js.map +1 -1
- package/dist/maas/index.d.ts +47 -45
- package/dist/maas/index.d.ts.map +1 -0
- package/dist/maas/index.js +109 -102
- package/dist/maas/index.js.map +1 -1
- package/dist/xai/edge/index.d.ts +77 -73
- package/dist/xai/edge/index.d.ts.map +1 -0
- package/dist/xai/edge/index.js +203 -235
- package/dist/xai/edge/index.js.map +1 -1
- package/dist/xai/index.d.ts +62 -59
- package/dist/xai/index.d.ts.map +1 -0
- package/dist/xai/index.js +138 -141
- package/dist/xai/index.js.map +1 -1
- package/docs/16-google-vertex.mdx +3 -3
- package/package.json +11 -11
- package/src/anthropic/google-vertex-anthropic-provider.ts +14 -4
- package/src/gemini-transcription/google-vertex-gemini-transcription-model.ts +5 -1
- package/src/google-vertex-provider-base.ts +28 -15
- package/src/google-vertex-transcription-model-options.ts +2 -1
- package/src/google-vertex-transcription-model.ts +13 -1
- package/src/maas/google-vertex-maas-provider.ts +18 -6
|
@@ -6,16 +6,18 @@ import {
|
|
|
6
6
|
type GoogleInteractionsModelId,
|
|
7
7
|
type GoogleInteractionsModelInput,
|
|
8
8
|
} from '@ai-sdk/google/internal';
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
import {
|
|
10
|
+
InvalidArgumentError,
|
|
11
|
+
type Experimental_VideoModelV4,
|
|
12
|
+
type ImageModelV4,
|
|
13
|
+
type LanguageModelV4,
|
|
14
|
+
type ProviderV4,
|
|
15
|
+
type SpeechModelV4,
|
|
16
|
+
type TranscriptionModelV4,
|
|
16
17
|
} from '@ai-sdk/provider';
|
|
17
18
|
import {
|
|
18
19
|
generateId,
|
|
20
|
+
isValidHostnamePart,
|
|
19
21
|
loadOptionalSetting,
|
|
20
22
|
loadSetting,
|
|
21
23
|
normalizeHeaders,
|
|
@@ -225,13 +227,22 @@ export function createGoogleVertex(
|
|
|
225
227
|
description: 'Google Vertex project',
|
|
226
228
|
});
|
|
227
229
|
|
|
228
|
-
const loadGoogleVertexLocation = () =>
|
|
229
|
-
loadSetting({
|
|
230
|
+
const loadGoogleVertexLocation = () => {
|
|
231
|
+
const location = loadSetting({
|
|
230
232
|
settingValue: options.location,
|
|
231
233
|
settingName: 'location',
|
|
232
234
|
environmentVariableName: 'GOOGLE_VERTEX_LOCATION',
|
|
233
235
|
description: 'Google Vertex location',
|
|
234
236
|
});
|
|
237
|
+
if (!isValidHostnamePart(location)) {
|
|
238
|
+
throw new InvalidArgumentError({
|
|
239
|
+
argument: 'location',
|
|
240
|
+
message:
|
|
241
|
+
'Invalid Google Vertex location. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return location;
|
|
245
|
+
};
|
|
235
246
|
|
|
236
247
|
// Tuned models are addressed via their deployed endpoint
|
|
237
248
|
// `.../locations/{region}/endpoints/{id}` instead of the base-model
|
|
@@ -242,6 +253,11 @@ export function createGoogleVertex(
|
|
|
242
253
|
return withoutTrailingSlash(options.baseURL) ?? EXPRESS_MODE_BASE_URL;
|
|
243
254
|
}
|
|
244
255
|
|
|
256
|
+
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
257
|
+
if (baseURL != null) {
|
|
258
|
+
return baseURL;
|
|
259
|
+
}
|
|
260
|
+
|
|
245
261
|
const region = loadGoogleVertexLocation();
|
|
246
262
|
const project = loadGoogleVertexProject();
|
|
247
263
|
|
|
@@ -255,12 +271,9 @@ export function createGoogleVertex(
|
|
|
255
271
|
}
|
|
256
272
|
};
|
|
257
273
|
|
|
258
|
-
return (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
endpoint ? '' : '/publishers/google'
|
|
262
|
-
}`
|
|
263
|
-
);
|
|
274
|
+
return `https://${getHost()}/v1beta1/projects/${project}/locations/${region}${
|
|
275
|
+
endpoint ? '' : '/publishers/google'
|
|
276
|
+
}`;
|
|
264
277
|
};
|
|
265
278
|
|
|
266
279
|
const createConfig = (
|
|
@@ -32,7 +32,8 @@ export const googleVertexTranscriptionProviderOptionsSchema = z.object({
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
|
|
35
|
-
* `'us-central1'`). Defaults to the provider `location`.
|
|
35
|
+
* `'us-central1'`). Defaults to the provider `location`. Must be a single
|
|
36
|
+
* DNS label (letters, digits, and hyphens).
|
|
36
37
|
*
|
|
37
38
|
* Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
|
|
38
39
|
* available in specific Speech-to-Text regions and is not available in the
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
InvalidArgumentError,
|
|
3
|
+
type SharedV4Warning,
|
|
4
|
+
type TranscriptionModelV4,
|
|
5
|
+
} from '@ai-sdk/provider';
|
|
2
6
|
import {
|
|
3
7
|
combineHeaders,
|
|
4
8
|
convertUint8ArrayToBase64,
|
|
5
9
|
createJsonResponseHandler,
|
|
10
|
+
isValidHostnamePart,
|
|
6
11
|
parseProviderOptions,
|
|
7
12
|
postJsonToApi,
|
|
8
13
|
resolve,
|
|
@@ -106,6 +111,13 @@ export class GoogleVertexTranscriptionModel implements TranscriptionModelV4 {
|
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
const region = googleOptions?.region ?? this.config.location;
|
|
114
|
+
if (!isValidHostnamePart(region)) {
|
|
115
|
+
throw new InvalidArgumentError({
|
|
116
|
+
argument: googleOptions?.region != null ? 'region' : 'location',
|
|
117
|
+
message:
|
|
118
|
+
'Invalid Google Cloud Speech-to-Text region. Expected a single DNS label (letters, digits, and hyphens).',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
109
121
|
const languageCodes = googleOptions?.languageCodes ?? ['auto'];
|
|
110
122
|
|
|
111
123
|
// The recognize API takes base64-encoded audio in the `content` field. A
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { InvalidArgumentError } from '@ai-sdk/provider';
|
|
1
2
|
import {
|
|
2
3
|
createOpenAICompatible,
|
|
3
4
|
type OpenAICompatibleProvider,
|
|
4
5
|
} from '@ai-sdk/openai-compatible';
|
|
5
6
|
import {
|
|
7
|
+
isValidHostnamePart,
|
|
6
8
|
loadOptionalSetting,
|
|
7
9
|
loadSetting,
|
|
8
10
|
withoutTrailingSlash,
|
|
@@ -74,11 +76,21 @@ export function createGoogleVertexMaas(
|
|
|
74
76
|
options: GoogleVertexMaasProviderSettings = {},
|
|
75
77
|
): GoogleVertexMaasProvider {
|
|
76
78
|
// Lazy-load settings to support loading from environment variables at runtime
|
|
77
|
-
const loadLocation = () =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const loadLocation = () => {
|
|
80
|
+
const location =
|
|
81
|
+
loadOptionalSetting({
|
|
82
|
+
settingValue: options.location,
|
|
83
|
+
environmentVariableName: 'GOOGLE_VERTEX_LOCATION',
|
|
84
|
+
}) ?? 'global';
|
|
85
|
+
if (!isValidHostnamePart(location)) {
|
|
86
|
+
throw new InvalidArgumentError({
|
|
87
|
+
argument: 'location',
|
|
88
|
+
message:
|
|
89
|
+
'Invalid Google Vertex location. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return location;
|
|
93
|
+
};
|
|
82
94
|
|
|
83
95
|
const loadProject = () =>
|
|
84
96
|
loadSetting({
|
|
@@ -100,7 +112,7 @@ export function createGoogleVertexMaas(
|
|
|
100
112
|
|
|
101
113
|
const constructBaseURL = () => {
|
|
102
114
|
const projectId = loadProject();
|
|
103
|
-
const location = loadLocation()
|
|
115
|
+
const location = loadLocation();
|
|
104
116
|
|
|
105
117
|
return `https://${getHost(location)}/v1/projects/${projectId}/locations/${location}/endpoints/openapi`;
|
|
106
118
|
};
|