@ai-sdk/google-vertex 4.0.231 → 4.0.233
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 +13 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/anthropic/edge/index.mjs +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.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 +4 -1
- package/package.json +2 -2
- package/src/google-vertex-transcription-model-options.ts +2 -1
- package/src/google-vertex-transcription-model.ts +22 -1
package/dist/edge/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "@ai-sdk/provider-utils";
|
|
18
18
|
|
|
19
19
|
// src/version.ts
|
|
20
|
-
var VERSION = true ? "4.0.
|
|
20
|
+
var VERSION = true ? "4.0.233" : "0.0.0-test";
|
|
21
21
|
|
|
22
22
|
// src/google-vertex-embedding-model.ts
|
|
23
23
|
import {
|
|
@@ -634,6 +634,9 @@ var googleVertexTools = {
|
|
|
634
634
|
};
|
|
635
635
|
|
|
636
636
|
// src/google-vertex-transcription-model.ts
|
|
637
|
+
import {
|
|
638
|
+
InvalidArgumentError
|
|
639
|
+
} from "@ai-sdk/provider";
|
|
637
640
|
import {
|
|
638
641
|
lazySchema as lazySchema6,
|
|
639
642
|
zodSchema as zodSchema6,
|
|
@@ -675,7 +678,8 @@ var googleVertexTranscriptionProviderOptionsSchema = lazySchema5(
|
|
|
675
678
|
enableWordTimeOffsets: z5.boolean().optional(),
|
|
676
679
|
/**
|
|
677
680
|
* The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
|
|
678
|
-
* `'us-central1'`). Defaults to the provider `location`.
|
|
681
|
+
* `'us-central1'`). Defaults to the provider `location`. Must be a single
|
|
682
|
+
* DNS label (letters, digits, and hyphens).
|
|
679
683
|
*
|
|
680
684
|
* Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
|
|
681
685
|
* available in specific Speech-to-Text regions and is not available in the
|
|
@@ -715,7 +719,7 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
715
719
|
return this.config.provider;
|
|
716
720
|
}
|
|
717
721
|
async doGenerate(options) {
|
|
718
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
722
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
719
723
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
720
724
|
const warnings = [];
|
|
721
725
|
let googleOptions;
|
|
@@ -730,7 +734,13 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
730
734
|
}
|
|
731
735
|
}
|
|
732
736
|
const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
|
|
733
|
-
|
|
737
|
+
if (((_e = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i.exec(region)) == null ? void 0 : _e[0]) !== region) {
|
|
738
|
+
throw new InvalidArgumentError({
|
|
739
|
+
argument: (googleOptions == null ? void 0 : googleOptions.region) != null ? "region" : "location",
|
|
740
|
+
message: "Invalid Google Cloud Speech-to-Text region. Expected a single DNS label (letters, digits, and hyphens)."
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
const languageCodes = (_f = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _f : ["auto"];
|
|
734
744
|
const content = typeof options.audio === "string" ? options.audio : convertUint8ArrayToBase642(options.audio);
|
|
735
745
|
const requestBody = {
|
|
736
746
|
config: {
|
|
@@ -740,14 +750,20 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
740
750
|
autoDecodingConfig: {},
|
|
741
751
|
features: {
|
|
742
752
|
// Word timing populates `segments`.
|
|
743
|
-
enableWordTimeOffsets: (
|
|
744
|
-
enableAutomaticPunctuation: (
|
|
753
|
+
enableWordTimeOffsets: (_g = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _g : true,
|
|
754
|
+
enableAutomaticPunctuation: (_h = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _h : true
|
|
745
755
|
}
|
|
746
756
|
},
|
|
747
757
|
content
|
|
748
758
|
};
|
|
749
759
|
const host = region === "global" ? "speech.googleapis.com" : `${region}-speech.googleapis.com`;
|
|
750
760
|
const url = `https://${host}/v2/projects/${this.config.project}/locations/${region}/recognizers/_:recognize`;
|
|
761
|
+
if (new URL(url).origin !== `https://${host.toLowerCase()}`) {
|
|
762
|
+
throw new InvalidArgumentError({
|
|
763
|
+
argument: (googleOptions == null ? void 0 : googleOptions.region) != null ? "region" : "location",
|
|
764
|
+
message: "Invalid Google Cloud Speech-to-Text endpoint origin."
|
|
765
|
+
});
|
|
766
|
+
}
|
|
751
767
|
const {
|
|
752
768
|
value: response,
|
|
753
769
|
responseHeaders,
|
|
@@ -766,7 +782,7 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
766
782
|
abortSignal: options.abortSignal,
|
|
767
783
|
fetch: this.config.fetch
|
|
768
784
|
});
|
|
769
|
-
const results = (
|
|
785
|
+
const results = (_i = response.results) != null ? _i : [];
|
|
770
786
|
const text = results.map((result) => {
|
|
771
787
|
var _a2, _b2, _c2;
|
|
772
788
|
return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
|
|
@@ -781,13 +797,13 @@ var GoogleVertexTranscriptionModel = class {
|
|
|
781
797
|
})) != null ? _d2 : [];
|
|
782
798
|
}
|
|
783
799
|
);
|
|
784
|
-
const language = convertBcp47ToIso6391((
|
|
800
|
+
const language = convertBcp47ToIso6391((_j = results[0]) == null ? void 0 : _j.languageCode);
|
|
785
801
|
return {
|
|
786
802
|
text,
|
|
787
803
|
segments,
|
|
788
804
|
language,
|
|
789
805
|
durationInSeconds: parseDurationSeconds(
|
|
790
|
-
(
|
|
806
|
+
(_k = response.metadata) == null ? void 0 : _k.totalBilledDuration
|
|
791
807
|
),
|
|
792
808
|
warnings,
|
|
793
809
|
response: {
|
|
@@ -828,7 +844,7 @@ var googleVertexTranscriptionResponseSchema = lazySchema6(
|
|
|
828
844
|
|
|
829
845
|
// src/gemini-transcription/google-vertex-gemini-transcription-model.ts
|
|
830
846
|
import {
|
|
831
|
-
InvalidArgumentError
|
|
847
|
+
InvalidArgumentError as InvalidArgumentError2
|
|
832
848
|
} from "@ai-sdk/provider";
|
|
833
849
|
import {
|
|
834
850
|
lazySchema as lazySchema8,
|
|
@@ -910,7 +926,7 @@ var GoogleVertexGeminiTranscriptionModel = class {
|
|
|
910
926
|
async doGenerate(options) {
|
|
911
927
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
912
928
|
if (isLiveTranscriptionModelId(this.modelId)) {
|
|
913
|
-
throw new
|
|
929
|
+
throw new InvalidArgumentError2({
|
|
914
930
|
argument: "modelId",
|
|
915
931
|
message: `Model '${this.modelId}' only supports streaming transcription, which requires AI SDK v7. Use a unary model such as 'gemini-3.5-transcribe'.`
|
|
916
932
|
});
|