@ai-sdk/google-vertex 4.0.230 → 4.0.232
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 +14 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/anthropic/edge/index.mjs +1 -1
- package/dist/edge/index.d.mts +1 -1
- package/dist/edge/index.d.ts +1 -1
- package/dist/edge/index.js +32 -18
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/index.mjs +27 -11
- package/dist/edge/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -9
- 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 +5 -1
- package/package.json +2 -2
- package/src/google-vertex-options.ts +1 -0
- package/src/google-vertex-transcription-model-options.ts +2 -1
- package/src/google-vertex-transcription-model.ts +22 -1
|
@@ -39,7 +39,8 @@ export const googleVertexTranscriptionProviderOptionsSchema = lazySchema(() =>
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
|
|
42
|
-
* `'us-central1'`). Defaults to the provider `location`.
|
|
42
|
+
* `'us-central1'`). Defaults to the provider `location`. Must be a single
|
|
43
|
+
* DNS label (letters, digits, and hyphens).
|
|
43
44
|
*
|
|
44
45
|
* Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
|
|
45
46
|
* available in specific Speech-to-Text regions and is not available in the
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
InvalidArgumentError,
|
|
3
|
+
type SharedV3Warning,
|
|
4
|
+
type TranscriptionModelV3,
|
|
5
|
+
} from '@ai-sdk/provider';
|
|
2
6
|
import {
|
|
3
7
|
lazySchema,
|
|
4
8
|
zodSchema,
|
|
@@ -91,6 +95,16 @@ export class GoogleVertexTranscriptionModel implements TranscriptionModelV3 {
|
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
const region = googleOptions?.region ?? this.config.location;
|
|
98
|
+
// Compare the full match because `$` also matches before a final newline.
|
|
99
|
+
if (
|
|
100
|
+
/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.exec(region)?.[0] !== region
|
|
101
|
+
) {
|
|
102
|
+
throw new InvalidArgumentError({
|
|
103
|
+
argument: googleOptions?.region != null ? 'region' : 'location',
|
|
104
|
+
message:
|
|
105
|
+
'Invalid Google Cloud Speech-to-Text region. Expected a single DNS label (letters, digits, and hyphens).',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
94
108
|
const languageCodes = googleOptions?.languageCodes ?? ['auto'];
|
|
95
109
|
|
|
96
110
|
// The recognize API takes base64-encoded audio in the `content` field. A
|
|
@@ -125,6 +139,13 @@ export class GoogleVertexTranscriptionModel implements TranscriptionModelV3 {
|
|
|
125
139
|
`https://${host}/v2/projects/` +
|
|
126
140
|
`${this.config.project}/locations/${region}/recognizers/_:recognize`;
|
|
127
141
|
|
|
142
|
+
if (new URL(url).origin !== `https://${host.toLowerCase()}`) {
|
|
143
|
+
throw new InvalidArgumentError({
|
|
144
|
+
argument: googleOptions?.region != null ? 'region' : 'location',
|
|
145
|
+
message: 'Invalid Google Cloud Speech-to-Text endpoint origin.',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
128
149
|
const {
|
|
129
150
|
value: response,
|
|
130
151
|
responseHeaders,
|