@ai-sdk/google-vertex 5.0.37 → 5.0.39
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 +32 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/edge/index.js +101 -76
- package/dist/edge/index.js.map +1 -1
- package/dist/index.js +101 -76
- package/dist/index.js.map +1 -1
- package/dist/maas/edge/index.js +1 -1
- package/dist/xai/edge/index.js +1 -1
- package/package.json +6 -6
- package/src/google-vertex-video-model.ts +146 -88
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
} from "@ai-sdk/provider-utils";
|
|
34
34
|
|
|
35
35
|
// src/version.ts
|
|
36
|
-
var VERSION = true ? "5.0.
|
|
36
|
+
var VERSION = true ? "5.0.39" : "0.0.0-test";
|
|
37
37
|
|
|
38
38
|
// src/google-vertex-embedding-model.ts
|
|
39
39
|
import {
|
|
@@ -855,7 +855,6 @@ import {
|
|
|
855
855
|
combineHeaders as combineHeaders4,
|
|
856
856
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase643,
|
|
857
857
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
858
|
-
delay,
|
|
859
858
|
parseProviderOptions as parseProviderOptions4,
|
|
860
859
|
postJsonToApi as postJsonToApi4,
|
|
861
860
|
resolve as resolve4
|
|
@@ -940,15 +939,14 @@ var GoogleVertexVideoModel = class {
|
|
|
940
939
|
get maxVideosPerCall() {
|
|
941
940
|
return 4;
|
|
942
941
|
}
|
|
943
|
-
async
|
|
944
|
-
var _a, _b
|
|
945
|
-
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
942
|
+
async buildRequest(options) {
|
|
943
|
+
var _a, _b;
|
|
946
944
|
const warnings = [];
|
|
947
|
-
const googleVertexOptions = (
|
|
945
|
+
const googleVertexOptions = (_a = await parseProviderOptions4({
|
|
948
946
|
provider: "googleVertex",
|
|
949
947
|
providerOptions: options.providerOptions,
|
|
950
948
|
schema: googleVertexVideoModelOptionsSchema
|
|
951
|
-
})) != null ?
|
|
949
|
+
})) != null ? _a : await parseProviderOptions4({
|
|
952
950
|
provider: "vertex",
|
|
953
951
|
providerOptions: options.providerOptions,
|
|
954
952
|
schema: googleVertexVideoModelOptionsSchema
|
|
@@ -1001,7 +999,7 @@ var GoogleVertexVideoModel = class {
|
|
|
1001
999
|
if (options.seed) {
|
|
1002
1000
|
parameters.seed = options.seed;
|
|
1003
1001
|
}
|
|
1004
|
-
const generateAudio = (
|
|
1002
|
+
const generateAudio = (_b = options.generateAudio) != null ? _b : googleVertexOptions == null ? void 0 : googleVertexOptions.generateAudio;
|
|
1005
1003
|
if (generateAudio != null) {
|
|
1006
1004
|
parameters.generateAudio = generateAudio;
|
|
1007
1005
|
}
|
|
@@ -1030,74 +1028,14 @@ var GoogleVertexVideoModel = class {
|
|
|
1030
1028
|
}
|
|
1031
1029
|
}
|
|
1032
1030
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
parameters
|
|
1042
|
-
},
|
|
1043
|
-
successfulResponseHandler: createJsonResponseHandler4(
|
|
1044
|
-
googleVertexOperationSchema
|
|
1045
|
-
),
|
|
1046
|
-
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
1047
|
-
abortSignal: options.abortSignal,
|
|
1048
|
-
fetch: this.config.fetch
|
|
1049
|
-
});
|
|
1050
|
-
const operationName = operation.name;
|
|
1051
|
-
if (!operationName) {
|
|
1052
|
-
throw new AISDKError({
|
|
1053
|
-
name: "VERTEX_VIDEO_GENERATION_ERROR",
|
|
1054
|
-
message: "No operation name returned from API"
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1057
|
-
const pollIntervalMs = (_f = googleVertexOptions == null ? void 0 : googleVertexOptions.pollIntervalMs) != null ? _f : 1e4;
|
|
1058
|
-
const pollTimeoutMs = (_g = googleVertexOptions == null ? void 0 : googleVertexOptions.pollTimeoutMs) != null ? _g : 6e5;
|
|
1059
|
-
const startTime = Date.now();
|
|
1060
|
-
let finalOperation = operation;
|
|
1061
|
-
let responseHeaders;
|
|
1062
|
-
while (!finalOperation.done) {
|
|
1063
|
-
if (Date.now() - startTime > pollTimeoutMs) {
|
|
1064
|
-
throw new AISDKError({
|
|
1065
|
-
name: "VERTEX_VIDEO_GENERATION_TIMEOUT",
|
|
1066
|
-
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
await delay(pollIntervalMs);
|
|
1070
|
-
if ((_h = options.abortSignal) == null ? void 0 : _h.aborted) {
|
|
1071
|
-
throw new AISDKError({
|
|
1072
|
-
name: "VERTEX_VIDEO_GENERATION_ABORTED",
|
|
1073
|
-
message: "Video generation request was aborted"
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi4({
|
|
1077
|
-
url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
|
|
1078
|
-
headers: combineHeaders4(
|
|
1079
|
-
await resolve4(this.config.headers),
|
|
1080
|
-
options.headers
|
|
1081
|
-
),
|
|
1082
|
-
body: {
|
|
1083
|
-
operationName
|
|
1084
|
-
},
|
|
1085
|
-
successfulResponseHandler: createJsonResponseHandler4(
|
|
1086
|
-
googleVertexOperationSchema
|
|
1087
|
-
),
|
|
1088
|
-
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
1089
|
-
abortSignal: options.abortSignal,
|
|
1090
|
-
fetch: this.config.fetch
|
|
1091
|
-
});
|
|
1092
|
-
finalOperation = statusOperation;
|
|
1093
|
-
responseHeaders = pollHeaders;
|
|
1094
|
-
}
|
|
1095
|
-
if (finalOperation.error) {
|
|
1096
|
-
throw new AISDKError({
|
|
1097
|
-
name: "VERTEX_VIDEO_GENERATION_FAILED",
|
|
1098
|
-
message: `Video generation failed: ${finalOperation.error.message}`
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1031
|
+
return { instances, parameters, warnings, googleVertexOptions };
|
|
1032
|
+
}
|
|
1033
|
+
buildCompletedResult({
|
|
1034
|
+
finalOperation,
|
|
1035
|
+
responseHeaders,
|
|
1036
|
+
warnings,
|
|
1037
|
+
currentDate
|
|
1038
|
+
}) {
|
|
1101
1039
|
const response = finalOperation.response;
|
|
1102
1040
|
if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
|
|
1103
1041
|
throw new AISDKError({
|
|
@@ -1136,6 +1074,7 @@ var GoogleVertexVideoModel = class {
|
|
|
1136
1074
|
});
|
|
1137
1075
|
}
|
|
1138
1076
|
return {
|
|
1077
|
+
status: "completed",
|
|
1139
1078
|
videos,
|
|
1140
1079
|
warnings,
|
|
1141
1080
|
response: {
|
|
@@ -1154,6 +1093,92 @@ var GoogleVertexVideoModel = class {
|
|
|
1154
1093
|
})()
|
|
1155
1094
|
};
|
|
1156
1095
|
}
|
|
1096
|
+
async doStart(options) {
|
|
1097
|
+
var _a, _b, _c;
|
|
1098
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1099
|
+
const { instances, parameters, warnings } = await this.buildRequest(options);
|
|
1100
|
+
const { value: operation, responseHeaders } = await postJsonToApi4({
|
|
1101
|
+
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
1102
|
+
headers: combineHeaders4(
|
|
1103
|
+
await resolve4(this.config.headers),
|
|
1104
|
+
options.headers
|
|
1105
|
+
),
|
|
1106
|
+
body: {
|
|
1107
|
+
instances,
|
|
1108
|
+
parameters
|
|
1109
|
+
},
|
|
1110
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
1111
|
+
googleVertexOperationSchema
|
|
1112
|
+
),
|
|
1113
|
+
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
1114
|
+
abortSignal: options.abortSignal,
|
|
1115
|
+
fetch: this.config.fetch
|
|
1116
|
+
});
|
|
1117
|
+
const operationName = operation.name;
|
|
1118
|
+
if (!operationName) {
|
|
1119
|
+
throw new AISDKError({
|
|
1120
|
+
name: "VERTEX_VIDEO_GENERATION_ERROR",
|
|
1121
|
+
message: "No operation name returned from API"
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
return {
|
|
1125
|
+
operation: { operationName },
|
|
1126
|
+
warnings,
|
|
1127
|
+
response: {
|
|
1128
|
+
timestamp: currentDate,
|
|
1129
|
+
modelId: this.modelId,
|
|
1130
|
+
headers: responseHeaders
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
async doStatus(options) {
|
|
1135
|
+
var _a, _b, _c;
|
|
1136
|
+
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
1137
|
+
const { operationName } = options.operation;
|
|
1138
|
+
const { value: statusOperation, responseHeaders } = await postJsonToApi4({
|
|
1139
|
+
url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
|
|
1140
|
+
headers: combineHeaders4(
|
|
1141
|
+
await resolve4(this.config.headers),
|
|
1142
|
+
options.headers
|
|
1143
|
+
),
|
|
1144
|
+
body: {
|
|
1145
|
+
operationName
|
|
1146
|
+
},
|
|
1147
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
1148
|
+
googleVertexOperationSchema
|
|
1149
|
+
),
|
|
1150
|
+
failedResponseHandler: googleVertexFailedResponseHandler,
|
|
1151
|
+
abortSignal: options.abortSignal,
|
|
1152
|
+
fetch: this.config.fetch
|
|
1153
|
+
});
|
|
1154
|
+
if (!statusOperation.done) {
|
|
1155
|
+
return {
|
|
1156
|
+
status: "pending",
|
|
1157
|
+
response: {
|
|
1158
|
+
timestamp: currentDate,
|
|
1159
|
+
modelId: this.modelId,
|
|
1160
|
+
headers: responseHeaders
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
if (statusOperation.error) {
|
|
1165
|
+
return {
|
|
1166
|
+
status: "error",
|
|
1167
|
+
error: `Video generation failed: ${statusOperation.error.message}`,
|
|
1168
|
+
response: {
|
|
1169
|
+
timestamp: currentDate,
|
|
1170
|
+
modelId: this.modelId,
|
|
1171
|
+
headers: responseHeaders
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
return this.buildCompletedResult({
|
|
1176
|
+
finalOperation: statusOperation,
|
|
1177
|
+
responseHeaders,
|
|
1178
|
+
warnings: [],
|
|
1179
|
+
currentDate
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1157
1182
|
};
|
|
1158
1183
|
var googleVertexOperationSchema = z9.object({
|
|
1159
1184
|
name: z9.string().nullish(),
|