@ai-sdk/google-vertex 4.0.146 → 4.0.147
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 +6 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/anthropic/edge/index.mjs +1 -1
- package/dist/edge/index.d.mts +11 -1
- package/dist/edge/index.d.ts +11 -1
- package/dist/edge/index.js +251 -62
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/index.mjs +243 -47
- package/dist/edge/index.mjs.map +1 -1
- package/dist/index.d.mts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +245 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +243 -47
- 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 +78 -0
- package/package.json +4 -4
- package/src/google-vertex-provider.ts +40 -0
- package/src/google-vertex-transcription-model-options.ts +46 -0
- package/src/google-vertex-transcription-model.ts +214 -0
- package/src/index.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ __export(index_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/google-vertex-provider-node.ts
|
|
30
|
-
var
|
|
30
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/google-vertex-auth-google-auth-library.ts
|
|
33
33
|
var import_google_auth_library = require("google-auth-library");
|
|
@@ -46,10 +46,10 @@ function createAuthTokenGenerator(options) {
|
|
|
46
46
|
|
|
47
47
|
// src/google-vertex-provider.ts
|
|
48
48
|
var import_internal3 = require("@ai-sdk/google/internal");
|
|
49
|
-
var
|
|
49
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
50
50
|
|
|
51
51
|
// src/version.ts
|
|
52
|
-
var VERSION = true ? "4.0.
|
|
52
|
+
var VERSION = true ? "4.0.147" : "0.0.0-test";
|
|
53
53
|
|
|
54
54
|
// src/google-vertex-embedding-model.ts
|
|
55
55
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -555,10 +555,182 @@ var googleVertexTools = {
|
|
|
555
555
|
vertexRagStore: import_internal2.googleTools.vertexRagStore
|
|
556
556
|
};
|
|
557
557
|
|
|
558
|
-
// src/google-vertex-
|
|
559
|
-
var import_provider2 = require("@ai-sdk/provider");
|
|
558
|
+
// src/google-vertex-transcription-model.ts
|
|
560
559
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
560
|
+
var import_v46 = require("zod/v4");
|
|
561
|
+
|
|
562
|
+
// src/google-vertex-transcription-model-options.ts
|
|
561
563
|
var import_v45 = require("zod/v4");
|
|
564
|
+
var googleVertexTranscriptionProviderOptionsSchema = import_v45.z.object({
|
|
565
|
+
/**
|
|
566
|
+
* BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
|
|
567
|
+
* Chirp auto-detect the spoken language. Defaults to `['auto']`. For
|
|
568
|
+
* `telephony`, pass a supported explicit language code.
|
|
569
|
+
*/
|
|
570
|
+
languageCodes: import_v45.z.array(import_v45.z.string()).optional(),
|
|
571
|
+
/**
|
|
572
|
+
* Whether to add punctuation to the transcript. Defaults to `true`.
|
|
573
|
+
*/
|
|
574
|
+
enableAutomaticPunctuation: import_v45.z.boolean().optional(),
|
|
575
|
+
/**
|
|
576
|
+
* Whether to include word-level timestamps. Defaults to `true` so the
|
|
577
|
+
* transcription result can include segments.
|
|
578
|
+
*
|
|
579
|
+
* Enabling word-level timestamps can reduce transcription quality and speed
|
|
580
|
+
* for Chirp models.
|
|
581
|
+
*/
|
|
582
|
+
enableWordTimeOffsets: import_v45.z.boolean().optional(),
|
|
583
|
+
/**
|
|
584
|
+
* The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
|
|
585
|
+
* `'us-central1'`). Defaults to the provider `location`.
|
|
586
|
+
*
|
|
587
|
+
* Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
|
|
588
|
+
* available in specific Speech-to-Text regions and is not available in the
|
|
589
|
+
* `global` location.
|
|
590
|
+
*/
|
|
591
|
+
region: import_v45.z.string().optional()
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// src/google-vertex-transcription-model.ts
|
|
595
|
+
function parseDurationSeconds(value) {
|
|
596
|
+
if (value == null) {
|
|
597
|
+
return void 0;
|
|
598
|
+
}
|
|
599
|
+
const seconds = Number.parseFloat(value);
|
|
600
|
+
return Number.isFinite(seconds) ? seconds : void 0;
|
|
601
|
+
}
|
|
602
|
+
function convertBcp47ToIso6391(value) {
|
|
603
|
+
if (value == null) {
|
|
604
|
+
return void 0;
|
|
605
|
+
}
|
|
606
|
+
try {
|
|
607
|
+
const language = new Intl.Locale(value).language;
|
|
608
|
+
return language.length === 2 ? language : void 0;
|
|
609
|
+
} catch (e) {
|
|
610
|
+
return void 0;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
var GoogleVertexTranscriptionModel = class {
|
|
614
|
+
constructor(modelId, config) {
|
|
615
|
+
this.modelId = modelId;
|
|
616
|
+
this.config = config;
|
|
617
|
+
this.specificationVersion = "v3";
|
|
618
|
+
}
|
|
619
|
+
get provider() {
|
|
620
|
+
return this.config.provider;
|
|
621
|
+
}
|
|
622
|
+
async doGenerate(options) {
|
|
623
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
624
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
625
|
+
const warnings = [];
|
|
626
|
+
let googleOptions;
|
|
627
|
+
for (const provider of ["googleVertex", "vertex", "google"]) {
|
|
628
|
+
googleOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
629
|
+
provider,
|
|
630
|
+
providerOptions: options.providerOptions,
|
|
631
|
+
schema: googleVertexTranscriptionProviderOptionsSchema
|
|
632
|
+
});
|
|
633
|
+
if (googleOptions != null) {
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
|
|
638
|
+
const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
|
|
639
|
+
const content = typeof options.audio === "string" ? options.audio : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.audio);
|
|
640
|
+
const requestBody = {
|
|
641
|
+
config: {
|
|
642
|
+
model: this.modelId,
|
|
643
|
+
languageCodes,
|
|
644
|
+
// Let Speech-to-Text auto-detect the audio encoding (wav/mp3/flac/…).
|
|
645
|
+
autoDecodingConfig: {},
|
|
646
|
+
features: {
|
|
647
|
+
// Word timing populates `segments`.
|
|
648
|
+
enableWordTimeOffsets: (_f = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _f : true,
|
|
649
|
+
enableAutomaticPunctuation: (_g = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _g : true
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
content
|
|
653
|
+
};
|
|
654
|
+
const host = region === "global" ? "speech.googleapis.com" : `${region}-speech.googleapis.com`;
|
|
655
|
+
const url = `https://${host}/v2/projects/${this.config.project}/locations/${region}/recognizers/_:recognize`;
|
|
656
|
+
const {
|
|
657
|
+
value: response,
|
|
658
|
+
responseHeaders,
|
|
659
|
+
rawValue: rawResponse
|
|
660
|
+
} = await (0, import_provider_utils4.postJsonToApi)({
|
|
661
|
+
url,
|
|
662
|
+
headers: (0, import_provider_utils4.combineHeaders)(
|
|
663
|
+
this.config.headers ? await (0, import_provider_utils4.resolve)(this.config.headers) : void 0,
|
|
664
|
+
options.headers
|
|
665
|
+
),
|
|
666
|
+
body: requestBody,
|
|
667
|
+
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
668
|
+
successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
|
|
669
|
+
googleVertexTranscriptionResponseSchema
|
|
670
|
+
),
|
|
671
|
+
abortSignal: options.abortSignal,
|
|
672
|
+
fetch: this.config.fetch
|
|
673
|
+
});
|
|
674
|
+
const results = (_h = response.results) != null ? _h : [];
|
|
675
|
+
const text = results.map((result) => {
|
|
676
|
+
var _a2, _b2, _c2;
|
|
677
|
+
return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
|
|
678
|
+
}).join(" ").trim();
|
|
679
|
+
const segments = results.flatMap(
|
|
680
|
+
(result) => {
|
|
681
|
+
var _a2, _b2, _c2, _d2;
|
|
682
|
+
return (_d2 = (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.words) == null ? void 0 : _c2.flatMap((word) => {
|
|
683
|
+
const startSecond = parseDurationSeconds(word.startOffset);
|
|
684
|
+
const endSecond = parseDurationSeconds(word.endOffset);
|
|
685
|
+
return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
|
|
686
|
+
})) != null ? _d2 : [];
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
const language = convertBcp47ToIso6391((_i = results[0]) == null ? void 0 : _i.languageCode);
|
|
690
|
+
return {
|
|
691
|
+
text,
|
|
692
|
+
segments,
|
|
693
|
+
language,
|
|
694
|
+
durationInSeconds: parseDurationSeconds(
|
|
695
|
+
(_j = response.metadata) == null ? void 0 : _j.totalBilledDuration
|
|
696
|
+
),
|
|
697
|
+
warnings,
|
|
698
|
+
response: {
|
|
699
|
+
timestamp: currentDate,
|
|
700
|
+
modelId: this.modelId,
|
|
701
|
+
headers: responseHeaders,
|
|
702
|
+
body: rawResponse
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
var googleVertexTranscriptionResponseSchema = import_v46.z.object({
|
|
708
|
+
results: import_v46.z.array(
|
|
709
|
+
import_v46.z.object({
|
|
710
|
+
alternatives: import_v46.z.array(
|
|
711
|
+
import_v46.z.object({
|
|
712
|
+
transcript: import_v46.z.string().nullish(),
|
|
713
|
+
words: import_v46.z.array(
|
|
714
|
+
import_v46.z.object({
|
|
715
|
+
word: import_v46.z.string().nullish(),
|
|
716
|
+
startOffset: import_v46.z.string().nullish(),
|
|
717
|
+
endOffset: import_v46.z.string().nullish()
|
|
718
|
+
})
|
|
719
|
+
).nullish()
|
|
720
|
+
})
|
|
721
|
+
).nullish(),
|
|
722
|
+
languageCode: import_v46.z.string().nullish()
|
|
723
|
+
})
|
|
724
|
+
).nullish(),
|
|
725
|
+
metadata: import_v46.z.object({
|
|
726
|
+
totalBilledDuration: import_v46.z.string().nullish()
|
|
727
|
+
}).nullish()
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
// src/google-vertex-video-model.ts
|
|
731
|
+
var import_provider2 = require("@ai-sdk/provider");
|
|
732
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
733
|
+
var import_v47 = require("zod/v4");
|
|
562
734
|
var GoogleVertexVideoModel = class {
|
|
563
735
|
constructor(modelId, config) {
|
|
564
736
|
this.modelId = modelId;
|
|
@@ -575,7 +747,7 @@ var GoogleVertexVideoModel = class {
|
|
|
575
747
|
var _a, _b, _c, _d, _e, _f;
|
|
576
748
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
577
749
|
const warnings = [];
|
|
578
|
-
const vertexOptions = await (0,
|
|
750
|
+
const vertexOptions = await (0, import_provider_utils5.parseProviderOptions)({
|
|
579
751
|
provider: "vertex",
|
|
580
752
|
providerOptions: options.providerOptions,
|
|
581
753
|
schema: googleVertexVideoModelOptionsSchema
|
|
@@ -593,7 +765,7 @@ var GoogleVertexVideoModel = class {
|
|
|
593
765
|
details: "Vertex AI video models require base64-encoded images or GCS URIs. URL will be ignored."
|
|
594
766
|
});
|
|
595
767
|
} else {
|
|
596
|
-
const base64Data = typeof options.image.data === "string" ? options.image.data : (0,
|
|
768
|
+
const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils5.convertUint8ArrayToBase64)(options.image.data);
|
|
597
769
|
instance.image = {
|
|
598
770
|
bytesBase64Encoded: base64Data,
|
|
599
771
|
mimeType: options.image.mediaType
|
|
@@ -651,17 +823,17 @@ var GoogleVertexVideoModel = class {
|
|
|
651
823
|
}
|
|
652
824
|
}
|
|
653
825
|
}
|
|
654
|
-
const { value: operation } = await (0,
|
|
826
|
+
const { value: operation } = await (0, import_provider_utils5.postJsonToApi)({
|
|
655
827
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
656
|
-
headers: (0,
|
|
657
|
-
await (0,
|
|
828
|
+
headers: (0, import_provider_utils5.combineHeaders)(
|
|
829
|
+
await (0, import_provider_utils5.resolve)(this.config.headers),
|
|
658
830
|
options.headers
|
|
659
831
|
),
|
|
660
832
|
body: {
|
|
661
833
|
instances,
|
|
662
834
|
parameters
|
|
663
835
|
},
|
|
664
|
-
successfulResponseHandler: (0,
|
|
836
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
665
837
|
vertexOperationSchema
|
|
666
838
|
),
|
|
667
839
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
@@ -687,23 +859,23 @@ var GoogleVertexVideoModel = class {
|
|
|
687
859
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
688
860
|
});
|
|
689
861
|
}
|
|
690
|
-
await (0,
|
|
862
|
+
await (0, import_provider_utils5.delay)(pollIntervalMs);
|
|
691
863
|
if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
|
|
692
864
|
throw new import_provider2.AISDKError({
|
|
693
865
|
name: "VERTEX_VIDEO_GENERATION_ABORTED",
|
|
694
866
|
message: "Video generation request was aborted"
|
|
695
867
|
});
|
|
696
868
|
}
|
|
697
|
-
const { value: statusOperation, responseHeaders: pollHeaders } = await (0,
|
|
869
|
+
const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils5.postJsonToApi)({
|
|
698
870
|
url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
|
|
699
|
-
headers: (0,
|
|
700
|
-
await (0,
|
|
871
|
+
headers: (0, import_provider_utils5.combineHeaders)(
|
|
872
|
+
await (0, import_provider_utils5.resolve)(this.config.headers),
|
|
701
873
|
options.headers
|
|
702
874
|
),
|
|
703
875
|
body: {
|
|
704
876
|
operationName
|
|
705
877
|
},
|
|
706
|
-
successfulResponseHandler: (0,
|
|
878
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
707
879
|
vertexOperationSchema
|
|
708
880
|
),
|
|
709
881
|
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
@@ -772,38 +944,38 @@ var GoogleVertexVideoModel = class {
|
|
|
772
944
|
};
|
|
773
945
|
}
|
|
774
946
|
};
|
|
775
|
-
var vertexOperationSchema =
|
|
776
|
-
name:
|
|
777
|
-
done:
|
|
778
|
-
error:
|
|
779
|
-
code:
|
|
780
|
-
message:
|
|
781
|
-
status:
|
|
947
|
+
var vertexOperationSchema = import_v47.z.object({
|
|
948
|
+
name: import_v47.z.string().nullish(),
|
|
949
|
+
done: import_v47.z.boolean().nullish(),
|
|
950
|
+
error: import_v47.z.object({
|
|
951
|
+
code: import_v47.z.number().nullish(),
|
|
952
|
+
message: import_v47.z.string(),
|
|
953
|
+
status: import_v47.z.string().nullish()
|
|
782
954
|
}).nullish(),
|
|
783
|
-
response:
|
|
784
|
-
videos:
|
|
785
|
-
|
|
786
|
-
bytesBase64Encoded:
|
|
787
|
-
gcsUri:
|
|
788
|
-
mimeType:
|
|
955
|
+
response: import_v47.z.object({
|
|
956
|
+
videos: import_v47.z.array(
|
|
957
|
+
import_v47.z.object({
|
|
958
|
+
bytesBase64Encoded: import_v47.z.string().nullish(),
|
|
959
|
+
gcsUri: import_v47.z.string().nullish(),
|
|
960
|
+
mimeType: import_v47.z.string().nullish()
|
|
789
961
|
})
|
|
790
962
|
).nullish(),
|
|
791
|
-
raiMediaFilteredCount:
|
|
963
|
+
raiMediaFilteredCount: import_v47.z.number().nullish()
|
|
792
964
|
}).nullish()
|
|
793
965
|
});
|
|
794
|
-
var googleVertexVideoModelOptionsSchema = (0,
|
|
795
|
-
() => (0,
|
|
796
|
-
|
|
797
|
-
pollIntervalMs:
|
|
798
|
-
pollTimeoutMs:
|
|
799
|
-
personGeneration:
|
|
800
|
-
negativePrompt:
|
|
801
|
-
generateAudio:
|
|
802
|
-
gcsOutputDirectory:
|
|
803
|
-
referenceImages:
|
|
804
|
-
|
|
805
|
-
bytesBase64Encoded:
|
|
806
|
-
gcsUri:
|
|
966
|
+
var googleVertexVideoModelOptionsSchema = (0, import_provider_utils5.lazySchema)(
|
|
967
|
+
() => (0, import_provider_utils5.zodSchema)(
|
|
968
|
+
import_v47.z.object({
|
|
969
|
+
pollIntervalMs: import_v47.z.number().positive().nullish(),
|
|
970
|
+
pollTimeoutMs: import_v47.z.number().positive().nullish(),
|
|
971
|
+
personGeneration: import_v47.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
972
|
+
negativePrompt: import_v47.z.string().nullish(),
|
|
973
|
+
generateAudio: import_v47.z.boolean().nullish(),
|
|
974
|
+
gcsOutputDirectory: import_v47.z.string().nullish(),
|
|
975
|
+
referenceImages: import_v47.z.array(
|
|
976
|
+
import_v47.z.object({
|
|
977
|
+
bytesBase64Encoded: import_v47.z.string().nullish(),
|
|
978
|
+
gcsUri: import_v47.z.string().nullish()
|
|
807
979
|
})
|
|
808
980
|
).nullish()
|
|
809
981
|
}).passthrough()
|
|
@@ -817,7 +989,7 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
817
989
|
const modifiedInit = {
|
|
818
990
|
...init,
|
|
819
991
|
headers: {
|
|
820
|
-
...(init == null ? void 0 : init.headers) ? (0,
|
|
992
|
+
...(init == null ? void 0 : init.headers) ? (0, import_provider_utils6.normalizeHeaders)(init.headers) : {},
|
|
821
993
|
"x-goog-api-key": apiKey
|
|
822
994
|
}
|
|
823
995
|
};
|
|
@@ -825,17 +997,17 @@ function createExpressModeFetch(apiKey, customFetch) {
|
|
|
825
997
|
};
|
|
826
998
|
}
|
|
827
999
|
function createVertex(options = {}) {
|
|
828
|
-
const apiKey = (0,
|
|
1000
|
+
const apiKey = (0, import_provider_utils6.loadOptionalSetting)({
|
|
829
1001
|
settingValue: options.apiKey,
|
|
830
1002
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
831
1003
|
});
|
|
832
|
-
const loadVertexProject = () => (0,
|
|
1004
|
+
const loadVertexProject = () => (0, import_provider_utils6.loadSetting)({
|
|
833
1005
|
settingValue: options.project,
|
|
834
1006
|
settingName: "project",
|
|
835
1007
|
environmentVariableName: "GOOGLE_VERTEX_PROJECT",
|
|
836
1008
|
description: "Google Vertex project"
|
|
837
1009
|
});
|
|
838
|
-
const loadVertexLocation = () => (0,
|
|
1010
|
+
const loadVertexLocation = () => (0, import_provider_utils6.loadSetting)({
|
|
839
1011
|
settingValue: options.location,
|
|
840
1012
|
settingName: "location",
|
|
841
1013
|
environmentVariableName: "GOOGLE_VERTEX_LOCATION",
|
|
@@ -844,7 +1016,7 @@ function createVertex(options = {}) {
|
|
|
844
1016
|
const loadBaseURL = () => {
|
|
845
1017
|
var _a, _b;
|
|
846
1018
|
if (apiKey) {
|
|
847
|
-
return (_a = (0,
|
|
1019
|
+
return (_a = (0, import_provider_utils6.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
|
|
848
1020
|
}
|
|
849
1021
|
const region = loadVertexLocation();
|
|
850
1022
|
const project = loadVertexProject();
|
|
@@ -857,13 +1029,13 @@ function createVertex(options = {}) {
|
|
|
857
1029
|
return `${region}-aiplatform.googleapis.com`;
|
|
858
1030
|
}
|
|
859
1031
|
};
|
|
860
|
-
return (_b = (0,
|
|
1032
|
+
return (_b = (0, import_provider_utils6.withoutTrailingSlash)(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
|
|
861
1033
|
};
|
|
862
1034
|
const createConfig = (name) => {
|
|
863
1035
|
const getHeaders = async () => {
|
|
864
1036
|
var _a;
|
|
865
|
-
const originalHeaders = await (0,
|
|
866
|
-
return (0,
|
|
1037
|
+
const originalHeaders = await (0, import_provider_utils6.resolve)((_a = options.headers) != null ? _a : {});
|
|
1038
|
+
return (0, import_provider_utils6.withUserAgentSuffix)(
|
|
867
1039
|
originalHeaders,
|
|
868
1040
|
`ai-sdk/google-vertex/${VERSION}`
|
|
869
1041
|
);
|
|
@@ -879,7 +1051,7 @@ function createVertex(options = {}) {
|
|
|
879
1051
|
var _a;
|
|
880
1052
|
return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
|
|
881
1053
|
...createConfig("chat"),
|
|
882
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1054
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils6.generateId,
|
|
883
1055
|
supportedUrls: () => ({
|
|
884
1056
|
"*": [
|
|
885
1057
|
// HTTP URLs:
|
|
@@ -895,14 +1067,29 @@ function createVertex(options = {}) {
|
|
|
895
1067
|
var _a;
|
|
896
1068
|
return new GoogleVertexImageModel(modelId, {
|
|
897
1069
|
...createConfig("image"),
|
|
898
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1070
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils6.generateId
|
|
899
1071
|
});
|
|
900
1072
|
};
|
|
901
1073
|
const createVideoModel = (modelId) => {
|
|
902
1074
|
var _a;
|
|
903
1075
|
return new GoogleVertexVideoModel(modelId, {
|
|
904
1076
|
...createConfig("video"),
|
|
905
|
-
generateId: (_a = options.generateId) != null ? _a :
|
|
1077
|
+
generateId: (_a = options.generateId) != null ? _a : import_provider_utils6.generateId
|
|
1078
|
+
});
|
|
1079
|
+
};
|
|
1080
|
+
const createTranscriptionModel = (modelId) => {
|
|
1081
|
+
if (apiKey) {
|
|
1082
|
+
throw new Error(
|
|
1083
|
+
"Google Vertex transcription models do not support Express Mode API keys. Use standard Google Cloud credentials instead."
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
const config = createConfig("transcription");
|
|
1087
|
+
return new GoogleVertexTranscriptionModel(modelId, {
|
|
1088
|
+
provider: config.provider,
|
|
1089
|
+
headers: config.headers,
|
|
1090
|
+
fetch: config.fetch,
|
|
1091
|
+
project: loadVertexProject(),
|
|
1092
|
+
location: loadVertexLocation()
|
|
906
1093
|
});
|
|
907
1094
|
};
|
|
908
1095
|
const provider = function(modelId) {
|
|
@@ -921,13 +1108,15 @@ function createVertex(options = {}) {
|
|
|
921
1108
|
provider.imageModel = createImageModel;
|
|
922
1109
|
provider.video = createVideoModel;
|
|
923
1110
|
provider.videoModel = createVideoModel;
|
|
1111
|
+
provider.transcription = createTranscriptionModel;
|
|
1112
|
+
provider.transcriptionModel = createTranscriptionModel;
|
|
924
1113
|
provider.tools = googleVertexTools;
|
|
925
1114
|
return provider;
|
|
926
1115
|
}
|
|
927
1116
|
|
|
928
1117
|
// src/google-vertex-provider-node.ts
|
|
929
1118
|
function createVertex2(options = {}) {
|
|
930
|
-
const apiKey = (0,
|
|
1119
|
+
const apiKey = (0, import_provider_utils7.loadOptionalSetting)({
|
|
931
1120
|
settingValue: options.apiKey,
|
|
932
1121
|
environmentVariableName: "GOOGLE_VERTEX_API_KEY"
|
|
933
1122
|
});
|
|
@@ -943,7 +1132,7 @@ function createVertex2(options = {}) {
|
|
|
943
1132
|
...options,
|
|
944
1133
|
headers: async () => ({
|
|
945
1134
|
Authorization: `Bearer ${await generateAuthToken()}`,
|
|
946
|
-
...await (0,
|
|
1135
|
+
...await (0, import_provider_utils7.resolve)(options.headers)
|
|
947
1136
|
})
|
|
948
1137
|
});
|
|
949
1138
|
}
|