@ai-sdk/google 4.0.0-beta.22 → 4.0.0-beta.24
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 +15 -0
- package/dist/index.d.mts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +251 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +262 -57
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +41 -10
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +46 -11
- package/dist/internal/index.mjs.map +1 -1
- package/docs/15-google-generative-ai.mdx +3 -3
- package/package.json +3 -3
- package/src/convert-to-google-generative-ai-messages.ts +58 -17
- package/src/google-generative-ai-files.ts +230 -0
- package/src/google-generative-ai-options.ts +1 -7
- package/src/google-generative-ai-prompt.ts +10 -2
- package/src/google-provider.ts +13 -0
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "4.0.0-beta.
|
|
10
|
+
var VERSION = true ? "4.0.0-beta.24" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -408,7 +408,11 @@ function isEmptyObjectSchema(jsonSchema) {
|
|
|
408
408
|
import {
|
|
409
409
|
UnsupportedFunctionalityError
|
|
410
410
|
} from "@ai-sdk/provider";
|
|
411
|
-
import {
|
|
411
|
+
import {
|
|
412
|
+
convertToBase64,
|
|
413
|
+
isProviderReference,
|
|
414
|
+
resolveProviderReference
|
|
415
|
+
} from "@ai-sdk/provider-utils";
|
|
412
416
|
var dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
|
|
413
417
|
function parseBase64DataUrl(value) {
|
|
414
418
|
const match = dataUrlRegex.exec(value);
|
|
@@ -543,19 +547,36 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
543
547
|
}
|
|
544
548
|
case "file": {
|
|
545
549
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
546
|
-
|
|
547
|
-
|
|
550
|
+
if (part.data instanceof URL) {
|
|
551
|
+
parts.push({
|
|
548
552
|
fileData: {
|
|
549
553
|
mimeType: mediaType,
|
|
550
554
|
fileUri: part.data.toString()
|
|
551
555
|
}
|
|
552
|
-
}
|
|
556
|
+
});
|
|
557
|
+
} else if (isProviderReference(part.data)) {
|
|
558
|
+
if (providerOptionsName === "vertex") {
|
|
559
|
+
throw new UnsupportedFunctionalityError({
|
|
560
|
+
functionality: "file parts with provider references"
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
parts.push({
|
|
564
|
+
fileData: {
|
|
565
|
+
mimeType: mediaType,
|
|
566
|
+
fileUri: resolveProviderReference({
|
|
567
|
+
reference: part.data,
|
|
568
|
+
provider: "google"
|
|
569
|
+
})
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
} else {
|
|
573
|
+
parts.push({
|
|
553
574
|
inlineData: {
|
|
554
575
|
mimeType: mediaType,
|
|
555
576
|
data: convertToBase64(part.data)
|
|
556
577
|
}
|
|
557
|
-
}
|
|
558
|
-
|
|
578
|
+
});
|
|
579
|
+
}
|
|
559
580
|
break;
|
|
560
581
|
}
|
|
561
582
|
}
|
|
@@ -606,6 +627,24 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
|
|
|
606
627
|
functionality: "File data URLs in assistant messages are not supported"
|
|
607
628
|
});
|
|
608
629
|
}
|
|
630
|
+
if (isProviderReference(part.data)) {
|
|
631
|
+
if (providerOptionsName === "vertex") {
|
|
632
|
+
throw new UnsupportedFunctionalityError({
|
|
633
|
+
functionality: "file parts with provider references"
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
return {
|
|
637
|
+
fileData: {
|
|
638
|
+
mimeType: part.mediaType,
|
|
639
|
+
fileUri: resolveProviderReference({
|
|
640
|
+
reference: part.data,
|
|
641
|
+
provider: "google"
|
|
642
|
+
})
|
|
643
|
+
},
|
|
644
|
+
...(providerOpts == null ? void 0 : providerOpts.thought) === true ? { thought: true } : {},
|
|
645
|
+
thoughtSignature
|
|
646
|
+
};
|
|
647
|
+
}
|
|
609
648
|
return {
|
|
610
649
|
inlineData: {
|
|
611
650
|
mimeType: part.mediaType,
|
|
@@ -846,11 +885,7 @@ var googleLanguageModelOptions = lazySchema4(
|
|
|
846
885
|
/**
|
|
847
886
|
* Optional. The service tier to use for the request.
|
|
848
887
|
*/
|
|
849
|
-
serviceTier: z4.enum([
|
|
850
|
-
"SERVICE_TIER_STANDARD",
|
|
851
|
-
"SERVICE_TIER_FLEX",
|
|
852
|
-
"SERVICE_TIER_PRIORITY"
|
|
853
|
-
]).optional()
|
|
888
|
+
serviceTier: z4.enum(["standard", "flex", "priority"]).optional()
|
|
854
889
|
})
|
|
855
890
|
)
|
|
856
891
|
);
|
|
@@ -2540,23 +2575,186 @@ var googleImageModelOptionsSchema = lazySchema11(
|
|
|
2540
2575
|
)
|
|
2541
2576
|
);
|
|
2542
2577
|
|
|
2543
|
-
// src/google-generative-ai-
|
|
2578
|
+
// src/google-generative-ai-files.ts
|
|
2544
2579
|
import {
|
|
2545
2580
|
AISDKError
|
|
2546
2581
|
} from "@ai-sdk/provider";
|
|
2547
2582
|
import {
|
|
2548
2583
|
combineHeaders as combineHeaders4,
|
|
2549
|
-
convertUint8ArrayToBase64,
|
|
2550
2584
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
2551
2585
|
delay,
|
|
2552
|
-
getFromApi,
|
|
2553
2586
|
lazySchema as lazySchema12,
|
|
2554
2587
|
parseProviderOptions as parseProviderOptions4,
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
zodSchema as zodSchema12
|
|
2588
|
+
zodSchema as zodSchema12,
|
|
2589
|
+
getFromApi
|
|
2558
2590
|
} from "@ai-sdk/provider-utils";
|
|
2559
2591
|
import { z as z14 } from "zod/v4";
|
|
2592
|
+
var GoogleGenerativeAIFiles = class {
|
|
2593
|
+
constructor(config) {
|
|
2594
|
+
this.config = config;
|
|
2595
|
+
this.specificationVersion = "v4";
|
|
2596
|
+
}
|
|
2597
|
+
get provider() {
|
|
2598
|
+
return this.config.provider;
|
|
2599
|
+
}
|
|
2600
|
+
async uploadFile(options) {
|
|
2601
|
+
var _a, _b, _c, _d;
|
|
2602
|
+
const googleOptions = await parseProviderOptions4({
|
|
2603
|
+
provider: "google",
|
|
2604
|
+
providerOptions: options.providerOptions,
|
|
2605
|
+
schema: googleFilesUploadOptionsSchema
|
|
2606
|
+
});
|
|
2607
|
+
const resolvedHeaders = this.config.headers();
|
|
2608
|
+
const fetchFn = (_a = this.config.fetch) != null ? _a : globalThis.fetch;
|
|
2609
|
+
const warnings = [];
|
|
2610
|
+
if (options.filename != null) {
|
|
2611
|
+
warnings.push({ type: "unsupported", feature: "filename" });
|
|
2612
|
+
}
|
|
2613
|
+
const data = options.data;
|
|
2614
|
+
const fileBytes = data instanceof Uint8Array ? data : Uint8Array.from(atob(data), (c) => c.charCodeAt(0));
|
|
2615
|
+
const mediaType = options.mediaType;
|
|
2616
|
+
const displayName = googleOptions == null ? void 0 : googleOptions.displayName;
|
|
2617
|
+
const baseOrigin = this.config.baseURL.replace(/\/v1beta$/, "");
|
|
2618
|
+
const initResponse = await fetchFn(`${baseOrigin}/upload/v1beta/files`, {
|
|
2619
|
+
method: "POST",
|
|
2620
|
+
headers: {
|
|
2621
|
+
...resolvedHeaders,
|
|
2622
|
+
"X-Goog-Upload-Protocol": "resumable",
|
|
2623
|
+
"X-Goog-Upload-Command": "start",
|
|
2624
|
+
"X-Goog-Upload-Header-Content-Length": String(fileBytes.length),
|
|
2625
|
+
"X-Goog-Upload-Header-Content-Type": mediaType,
|
|
2626
|
+
"Content-Type": "application/json"
|
|
2627
|
+
},
|
|
2628
|
+
body: JSON.stringify({
|
|
2629
|
+
file: {
|
|
2630
|
+
...displayName != null ? { display_name: displayName } : {}
|
|
2631
|
+
}
|
|
2632
|
+
})
|
|
2633
|
+
});
|
|
2634
|
+
if (!initResponse.ok) {
|
|
2635
|
+
const errorBody = await initResponse.text();
|
|
2636
|
+
throw new AISDKError({
|
|
2637
|
+
name: "GOOGLE_FILES_UPLOAD_ERROR",
|
|
2638
|
+
message: `Failed to initiate resumable upload: ${initResponse.status} ${errorBody}`
|
|
2639
|
+
});
|
|
2640
|
+
}
|
|
2641
|
+
const uploadUrl = initResponse.headers.get("x-goog-upload-url");
|
|
2642
|
+
if (!uploadUrl) {
|
|
2643
|
+
throw new AISDKError({
|
|
2644
|
+
name: "GOOGLE_FILES_UPLOAD_ERROR",
|
|
2645
|
+
message: "No upload URL returned from initiation request"
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
const uploadResponse = await fetchFn(uploadUrl, {
|
|
2649
|
+
method: "POST",
|
|
2650
|
+
headers: {
|
|
2651
|
+
"Content-Length": String(fileBytes.length),
|
|
2652
|
+
"X-Goog-Upload-Offset": "0",
|
|
2653
|
+
"X-Goog-Upload-Command": "upload, finalize"
|
|
2654
|
+
},
|
|
2655
|
+
body: fileBytes
|
|
2656
|
+
});
|
|
2657
|
+
if (!uploadResponse.ok) {
|
|
2658
|
+
const errorBody = await uploadResponse.text();
|
|
2659
|
+
throw new AISDKError({
|
|
2660
|
+
name: "GOOGLE_FILES_UPLOAD_ERROR",
|
|
2661
|
+
message: `Failed to upload file data: ${uploadResponse.status} ${errorBody}`
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
const uploadResult = await uploadResponse.json();
|
|
2665
|
+
let file = uploadResult.file;
|
|
2666
|
+
const pollIntervalMs = (_b = googleOptions == null ? void 0 : googleOptions.pollIntervalMs) != null ? _b : 2e3;
|
|
2667
|
+
const pollTimeoutMs = (_c = googleOptions == null ? void 0 : googleOptions.pollTimeoutMs) != null ? _c : 3e5;
|
|
2668
|
+
const startTime = Date.now();
|
|
2669
|
+
while (file.state === "PROCESSING") {
|
|
2670
|
+
if (Date.now() - startTime > pollTimeoutMs) {
|
|
2671
|
+
throw new AISDKError({
|
|
2672
|
+
name: "GOOGLE_FILES_UPLOAD_TIMEOUT",
|
|
2673
|
+
message: `File processing timed out after ${pollTimeoutMs}ms`
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
await delay(pollIntervalMs);
|
|
2677
|
+
const { value: fileStatus } = await getFromApi({
|
|
2678
|
+
url: `${this.config.baseURL}/${file.name}`,
|
|
2679
|
+
headers: combineHeaders4(resolvedHeaders),
|
|
2680
|
+
successfulResponseHandler: createJsonResponseHandler4(
|
|
2681
|
+
googleFileResponseSchema
|
|
2682
|
+
),
|
|
2683
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
2684
|
+
fetch: this.config.fetch
|
|
2685
|
+
});
|
|
2686
|
+
file = fileStatus;
|
|
2687
|
+
}
|
|
2688
|
+
if (file.state === "FAILED") {
|
|
2689
|
+
throw new AISDKError({
|
|
2690
|
+
name: "GOOGLE_FILES_UPLOAD_FAILED",
|
|
2691
|
+
message: `File processing failed for ${file.name}`
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
return {
|
|
2695
|
+
warnings,
|
|
2696
|
+
providerReference: { google: file.uri },
|
|
2697
|
+
mediaType: (_d = file.mimeType) != null ? _d : options.mediaType,
|
|
2698
|
+
providerMetadata: {
|
|
2699
|
+
google: {
|
|
2700
|
+
name: file.name,
|
|
2701
|
+
displayName: file.displayName,
|
|
2702
|
+
mimeType: file.mimeType,
|
|
2703
|
+
sizeBytes: file.sizeBytes,
|
|
2704
|
+
state: file.state,
|
|
2705
|
+
uri: file.uri,
|
|
2706
|
+
...file.createTime != null ? { createTime: file.createTime } : {},
|
|
2707
|
+
...file.updateTime != null ? { updateTime: file.updateTime } : {},
|
|
2708
|
+
...file.expirationTime != null ? { expirationTime: file.expirationTime } : {},
|
|
2709
|
+
...file.sha256Hash != null ? { sha256Hash: file.sha256Hash } : {}
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
};
|
|
2715
|
+
var googleFileResponseSchema = lazySchema12(
|
|
2716
|
+
() => zodSchema12(
|
|
2717
|
+
z14.object({
|
|
2718
|
+
name: z14.string(),
|
|
2719
|
+
displayName: z14.string().nullish(),
|
|
2720
|
+
mimeType: z14.string(),
|
|
2721
|
+
sizeBytes: z14.string().nullish(),
|
|
2722
|
+
createTime: z14.string().nullish(),
|
|
2723
|
+
updateTime: z14.string().nullish(),
|
|
2724
|
+
expirationTime: z14.string().nullish(),
|
|
2725
|
+
sha256Hash: z14.string().nullish(),
|
|
2726
|
+
uri: z14.string(),
|
|
2727
|
+
state: z14.string()
|
|
2728
|
+
})
|
|
2729
|
+
)
|
|
2730
|
+
);
|
|
2731
|
+
var googleFilesUploadOptionsSchema = lazySchema12(
|
|
2732
|
+
() => zodSchema12(
|
|
2733
|
+
z14.object({
|
|
2734
|
+
displayName: z14.string().nullish(),
|
|
2735
|
+
pollIntervalMs: z14.number().positive().nullish(),
|
|
2736
|
+
pollTimeoutMs: z14.number().positive().nullish()
|
|
2737
|
+
}).passthrough()
|
|
2738
|
+
)
|
|
2739
|
+
);
|
|
2740
|
+
|
|
2741
|
+
// src/google-generative-ai-video-model.ts
|
|
2742
|
+
import {
|
|
2743
|
+
AISDKError as AISDKError2
|
|
2744
|
+
} from "@ai-sdk/provider";
|
|
2745
|
+
import {
|
|
2746
|
+
combineHeaders as combineHeaders5,
|
|
2747
|
+
convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
|
|
2748
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
2749
|
+
delay as delay2,
|
|
2750
|
+
getFromApi as getFromApi2,
|
|
2751
|
+
lazySchema as lazySchema13,
|
|
2752
|
+
parseProviderOptions as parseProviderOptions5,
|
|
2753
|
+
postJsonToApi as postJsonToApi5,
|
|
2754
|
+
resolve as resolve4,
|
|
2755
|
+
zodSchema as zodSchema13
|
|
2756
|
+
} from "@ai-sdk/provider-utils";
|
|
2757
|
+
import { z as z15 } from "zod/v4";
|
|
2560
2758
|
var GoogleGenerativeAIVideoModel = class {
|
|
2561
2759
|
constructor(modelId, config) {
|
|
2562
2760
|
this.modelId = modelId;
|
|
@@ -2573,7 +2771,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2573
2771
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2574
2772
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
2575
2773
|
const warnings = [];
|
|
2576
|
-
const googleOptions = await
|
|
2774
|
+
const googleOptions = await parseProviderOptions5({
|
|
2577
2775
|
provider: "google",
|
|
2578
2776
|
providerOptions: options.providerOptions,
|
|
2579
2777
|
schema: googleVideoModelOptionsSchema
|
|
@@ -2591,7 +2789,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2591
2789
|
details: "Google Generative AI video models require base64-encoded images. URL will be ignored."
|
|
2592
2790
|
});
|
|
2593
2791
|
} else {
|
|
2594
|
-
const base64Data = typeof options.image.data === "string" ? options.image.data :
|
|
2792
|
+
const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase642(options.image.data);
|
|
2595
2793
|
instance.image = {
|
|
2596
2794
|
inlineData: {
|
|
2597
2795
|
mimeType: options.image.mediaType || "image/png",
|
|
@@ -2657,9 +2855,9 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2657
2855
|
}
|
|
2658
2856
|
}
|
|
2659
2857
|
}
|
|
2660
|
-
const { value: operation } = await
|
|
2858
|
+
const { value: operation } = await postJsonToApi5({
|
|
2661
2859
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
2662
|
-
headers:
|
|
2860
|
+
headers: combineHeaders5(
|
|
2663
2861
|
await resolve4(this.config.headers),
|
|
2664
2862
|
options.headers
|
|
2665
2863
|
),
|
|
@@ -2667,7 +2865,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2667
2865
|
instances,
|
|
2668
2866
|
parameters
|
|
2669
2867
|
},
|
|
2670
|
-
successfulResponseHandler:
|
|
2868
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
2671
2869
|
googleOperationSchema
|
|
2672
2870
|
),
|
|
2673
2871
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -2676,7 +2874,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2676
2874
|
});
|
|
2677
2875
|
const operationName = operation.name;
|
|
2678
2876
|
if (!operationName) {
|
|
2679
|
-
throw new
|
|
2877
|
+
throw new AISDKError2({
|
|
2680
2878
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
2681
2879
|
message: "No operation name returned from API"
|
|
2682
2880
|
});
|
|
@@ -2688,25 +2886,25 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2688
2886
|
let responseHeaders;
|
|
2689
2887
|
while (!finalOperation.done) {
|
|
2690
2888
|
if (Date.now() - startTime > pollTimeoutMs) {
|
|
2691
|
-
throw new
|
|
2889
|
+
throw new AISDKError2({
|
|
2692
2890
|
name: "GOOGLE_VIDEO_GENERATION_TIMEOUT",
|
|
2693
2891
|
message: `Video generation timed out after ${pollTimeoutMs}ms`
|
|
2694
2892
|
});
|
|
2695
2893
|
}
|
|
2696
|
-
await
|
|
2894
|
+
await delay2(pollIntervalMs);
|
|
2697
2895
|
if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
|
|
2698
|
-
throw new
|
|
2896
|
+
throw new AISDKError2({
|
|
2699
2897
|
name: "GOOGLE_VIDEO_GENERATION_ABORTED",
|
|
2700
2898
|
message: "Video generation request was aborted"
|
|
2701
2899
|
});
|
|
2702
2900
|
}
|
|
2703
|
-
const { value: statusOperation, responseHeaders: pollHeaders } = await
|
|
2901
|
+
const { value: statusOperation, responseHeaders: pollHeaders } = await getFromApi2({
|
|
2704
2902
|
url: `${this.config.baseURL}/${operationName}`,
|
|
2705
|
-
headers:
|
|
2903
|
+
headers: combineHeaders5(
|
|
2706
2904
|
await resolve4(this.config.headers),
|
|
2707
2905
|
options.headers
|
|
2708
2906
|
),
|
|
2709
|
-
successfulResponseHandler:
|
|
2907
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
2710
2908
|
googleOperationSchema
|
|
2711
2909
|
),
|
|
2712
2910
|
failedResponseHandler: googleFailedResponseHandler,
|
|
@@ -2717,14 +2915,14 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2717
2915
|
responseHeaders = pollHeaders;
|
|
2718
2916
|
}
|
|
2719
2917
|
if (finalOperation.error) {
|
|
2720
|
-
throw new
|
|
2918
|
+
throw new AISDKError2({
|
|
2721
2919
|
name: "GOOGLE_VIDEO_GENERATION_FAILED",
|
|
2722
2920
|
message: `Video generation failed: ${finalOperation.error.message}`
|
|
2723
2921
|
});
|
|
2724
2922
|
}
|
|
2725
2923
|
const response = finalOperation.response;
|
|
2726
2924
|
if (!((_g = response == null ? void 0 : response.generateVideoResponse) == null ? void 0 : _g.generatedSamples) || response.generateVideoResponse.generatedSamples.length === 0) {
|
|
2727
|
-
throw new
|
|
2925
|
+
throw new AISDKError2({
|
|
2728
2926
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
2729
2927
|
message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
|
|
2730
2928
|
});
|
|
@@ -2747,7 +2945,7 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2747
2945
|
}
|
|
2748
2946
|
}
|
|
2749
2947
|
if (videos.length === 0) {
|
|
2750
|
-
throw new
|
|
2948
|
+
throw new AISDKError2({
|
|
2751
2949
|
name: "GOOGLE_VIDEO_GENERATION_ERROR",
|
|
2752
2950
|
message: "No valid videos in response"
|
|
2753
2951
|
});
|
|
@@ -2768,37 +2966,37 @@ var GoogleGenerativeAIVideoModel = class {
|
|
|
2768
2966
|
};
|
|
2769
2967
|
}
|
|
2770
2968
|
};
|
|
2771
|
-
var googleOperationSchema =
|
|
2772
|
-
name:
|
|
2773
|
-
done:
|
|
2774
|
-
error:
|
|
2775
|
-
code:
|
|
2776
|
-
message:
|
|
2777
|
-
status:
|
|
2969
|
+
var googleOperationSchema = z15.object({
|
|
2970
|
+
name: z15.string().nullish(),
|
|
2971
|
+
done: z15.boolean().nullish(),
|
|
2972
|
+
error: z15.object({
|
|
2973
|
+
code: z15.number().nullish(),
|
|
2974
|
+
message: z15.string(),
|
|
2975
|
+
status: z15.string().nullish()
|
|
2778
2976
|
}).nullish(),
|
|
2779
|
-
response:
|
|
2780
|
-
generateVideoResponse:
|
|
2781
|
-
generatedSamples:
|
|
2782
|
-
|
|
2783
|
-
video:
|
|
2784
|
-
uri:
|
|
2977
|
+
response: z15.object({
|
|
2978
|
+
generateVideoResponse: z15.object({
|
|
2979
|
+
generatedSamples: z15.array(
|
|
2980
|
+
z15.object({
|
|
2981
|
+
video: z15.object({
|
|
2982
|
+
uri: z15.string().nullish()
|
|
2785
2983
|
}).nullish()
|
|
2786
2984
|
})
|
|
2787
2985
|
).nullish()
|
|
2788
2986
|
}).nullish()
|
|
2789
2987
|
}).nullish()
|
|
2790
2988
|
});
|
|
2791
|
-
var googleVideoModelOptionsSchema =
|
|
2792
|
-
() =>
|
|
2793
|
-
|
|
2794
|
-
pollIntervalMs:
|
|
2795
|
-
pollTimeoutMs:
|
|
2796
|
-
personGeneration:
|
|
2797
|
-
negativePrompt:
|
|
2798
|
-
referenceImages:
|
|
2799
|
-
|
|
2800
|
-
bytesBase64Encoded:
|
|
2801
|
-
gcsUri:
|
|
2989
|
+
var googleVideoModelOptionsSchema = lazySchema13(
|
|
2990
|
+
() => zodSchema13(
|
|
2991
|
+
z15.object({
|
|
2992
|
+
pollIntervalMs: z15.number().positive().nullish(),
|
|
2993
|
+
pollTimeoutMs: z15.number().positive().nullish(),
|
|
2994
|
+
personGeneration: z15.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
2995
|
+
negativePrompt: z15.string().nullish(),
|
|
2996
|
+
referenceImages: z15.array(
|
|
2997
|
+
z15.object({
|
|
2998
|
+
bytesBase64Encoded: z15.string().nullish(),
|
|
2999
|
+
gcsUri: z15.string().nullish()
|
|
2802
3000
|
})
|
|
2803
3001
|
).nullish()
|
|
2804
3002
|
}).passthrough()
|
|
@@ -2855,6 +3053,12 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
2855
3053
|
headers: getHeaders,
|
|
2856
3054
|
fetch: options.fetch
|
|
2857
3055
|
});
|
|
3056
|
+
const createFiles = () => new GoogleGenerativeAIFiles({
|
|
3057
|
+
provider: providerName,
|
|
3058
|
+
baseURL,
|
|
3059
|
+
headers: getHeaders,
|
|
3060
|
+
fetch: options.fetch
|
|
3061
|
+
});
|
|
2858
3062
|
const createVideoModel = (modelId) => {
|
|
2859
3063
|
var _a2;
|
|
2860
3064
|
return new GoogleGenerativeAIVideoModel(modelId, {
|
|
@@ -2885,6 +3089,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
2885
3089
|
provider.imageModel = createImageModel;
|
|
2886
3090
|
provider.video = createVideoModel;
|
|
2887
3091
|
provider.videoModel = createVideoModel;
|
|
3092
|
+
provider.files = createFiles;
|
|
2888
3093
|
provider.tools = googleTools;
|
|
2889
3094
|
return provider;
|
|
2890
3095
|
}
|