ai 6.0.216 → 6.0.218
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 +21 -0
- package/dist/index.d.mts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +79 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -115
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -3
- package/dist/internal/index.d.ts +1 -3
- package/dist/internal/index.js +10 -58
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +13 -59
- package/dist/internal/index.mjs.map +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/03-ai-sdk-core/16-mcp-tools.mdx +28 -0
- package/docs/03-ai-sdk-core/38-video-generation.mdx +40 -0
- package/docs/03-ai-sdk-core/40-middleware.mdx +3 -3
- package/docs/07-reference/01-ai-sdk-core/13-generate-video.mdx +12 -0
- package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +7 -0
- package/package.json +4 -4
- package/src/generate-video/generate-video.ts +142 -64
- package/src/util/prepare-retries.ts +2 -4
- package/src/util/retry-with-exponential-backoff.ts +27 -95
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.218
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ea1e95b: feat(mcp): add maxRetries option for failed mcp tool calls
|
|
8
|
+
- Updated dependencies [ea1e95b]
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.35
|
|
10
|
+
- @ai-sdk/gateway@3.0.142
|
|
11
|
+
|
|
12
|
+
## 6.0.217
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- fa850e6: feat (video): add first-class `frameImages` and `inputReferences` call options for video generation
|
|
17
|
+
- Updated dependencies [95bc6fd]
|
|
18
|
+
- Updated dependencies [f6b2159]
|
|
19
|
+
- Updated dependencies [fa850e6]
|
|
20
|
+
- @ai-sdk/gateway@3.0.141
|
|
21
|
+
- @ai-sdk/provider@3.0.13
|
|
22
|
+
- @ai-sdk/provider-utils@4.0.34
|
|
23
|
+
|
|
3
24
|
## 6.0.216
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, EmbeddingModelV3Middleware, ImageModelV3, ImageModelV2, ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV3Middleware, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, SharedV3Warning, LanguageModelV3Source, LanguageModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV3Usage, AISDKError, LanguageModelV3ToolCall, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3ToolChoice, ProviderV3, JSONParseError, TypeValidationError, Experimental_VideoModelV3, EmbeddingModelV3CallOptions, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
2
|
+
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, EmbeddingModelV3Middleware, ImageModelV3, ImageModelV2, ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV3Middleware, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, SharedV3Warning, LanguageModelV3Source, LanguageModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV3Usage, AISDKError, LanguageModelV3ToolCall, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3ToolChoice, ProviderV3, JSONParseError, TypeValidationError, Experimental_VideoModelV3, Experimental_VideoModelV3FrameType, EmbeddingModelV3CallOptions, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
3
3
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
4
4
|
import { GatewayModelId } from '@ai-sdk/gateway';
|
|
5
5
|
export { GatewayModelId, createGateway, gateway } from '@ai-sdk/gateway';
|
|
@@ -5863,7 +5863,7 @@ type GenerateVideoPrompt = string | {
|
|
|
5863
5863
|
image: DataContent;
|
|
5864
5864
|
text?: string;
|
|
5865
5865
|
};
|
|
5866
|
-
declare function experimental_generateVideo({ model: modelArg, prompt: promptArg, n, maxVideosPerCall, aspectRatio, resolution, duration, fps, seed, generateAudio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn, }: {
|
|
5866
|
+
declare function experimental_generateVideo({ model: modelArg, prompt: promptArg, n, maxVideosPerCall, aspectRatio, resolution, duration, fps, seed, frameImages, inputReferences, generateAudio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn, }: {
|
|
5867
5867
|
/**
|
|
5868
5868
|
* The video model to use.
|
|
5869
5869
|
*/
|
|
@@ -5900,6 +5900,23 @@ declare function experimental_generateVideo({ model: modelArg, prompt: promptArg
|
|
|
5900
5900
|
* Seed for the video generation.
|
|
5901
5901
|
*/
|
|
5902
5902
|
seed?: number;
|
|
5903
|
+
/**
|
|
5904
|
+
* Role-tagged image inputs for image-to-video and first-last-frame generation.
|
|
5905
|
+
*/
|
|
5906
|
+
frameImages?: Array<{
|
|
5907
|
+
/**
|
|
5908
|
+
* The image for this frame.
|
|
5909
|
+
*/
|
|
5910
|
+
image: DataContent;
|
|
5911
|
+
/**
|
|
5912
|
+
* Which frame this image represents.
|
|
5913
|
+
*/
|
|
5914
|
+
frameType: Experimental_VideoModelV3FrameType;
|
|
5915
|
+
}>;
|
|
5916
|
+
/**
|
|
5917
|
+
* Reference image inputs for reference-to-video generation.
|
|
5918
|
+
*/
|
|
5919
|
+
inputReferences?: Array<DataContent>;
|
|
5903
5920
|
/**
|
|
5904
5921
|
* Whether the model should generate audio alongside the video.
|
|
5905
5922
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, EmbeddingModelV3Middleware, ImageModelV3, ImageModelV2, ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV3Middleware, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, SharedV3Warning, LanguageModelV3Source, LanguageModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV3Usage, AISDKError, LanguageModelV3ToolCall, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3ToolChoice, ProviderV3, JSONParseError, TypeValidationError, Experimental_VideoModelV3, EmbeddingModelV3CallOptions, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
2
|
+
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, EmbeddingModelV3Middleware, ImageModelV3, ImageModelV2, ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV3Middleware, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, SharedV3Warning, LanguageModelV3Source, LanguageModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV3Usage, AISDKError, LanguageModelV3ToolCall, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3ToolChoice, ProviderV3, JSONParseError, TypeValidationError, Experimental_VideoModelV3, Experimental_VideoModelV3FrameType, EmbeddingModelV3CallOptions, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
3
3
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
4
4
|
import { GatewayModelId } from '@ai-sdk/gateway';
|
|
5
5
|
export { GatewayModelId, createGateway, gateway } from '@ai-sdk/gateway';
|
|
@@ -5863,7 +5863,7 @@ type GenerateVideoPrompt = string | {
|
|
|
5863
5863
|
image: DataContent;
|
|
5864
5864
|
text?: string;
|
|
5865
5865
|
};
|
|
5866
|
-
declare function experimental_generateVideo({ model: modelArg, prompt: promptArg, n, maxVideosPerCall, aspectRatio, resolution, duration, fps, seed, generateAudio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn, }: {
|
|
5866
|
+
declare function experimental_generateVideo({ model: modelArg, prompt: promptArg, n, maxVideosPerCall, aspectRatio, resolution, duration, fps, seed, frameImages, inputReferences, generateAudio, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, download: downloadFn, }: {
|
|
5867
5867
|
/**
|
|
5868
5868
|
* The video model to use.
|
|
5869
5869
|
*/
|
|
@@ -5900,6 +5900,23 @@ declare function experimental_generateVideo({ model: modelArg, prompt: promptArg
|
|
|
5900
5900
|
* Seed for the video generation.
|
|
5901
5901
|
*/
|
|
5902
5902
|
seed?: number;
|
|
5903
|
+
/**
|
|
5904
|
+
* Role-tagged image inputs for image-to-video and first-last-frame generation.
|
|
5905
|
+
*/
|
|
5906
|
+
frameImages?: Array<{
|
|
5907
|
+
/**
|
|
5908
|
+
* The image for this frame.
|
|
5909
|
+
*/
|
|
5910
|
+
image: DataContent;
|
|
5911
|
+
/**
|
|
5912
|
+
* Which frame this image represents.
|
|
5913
|
+
*/
|
|
5914
|
+
frameType: Experimental_VideoModelV3FrameType;
|
|
5915
|
+
}>;
|
|
5916
|
+
/**
|
|
5917
|
+
* Reference image inputs for reference-to-video generation.
|
|
5918
|
+
*/
|
|
5919
|
+
inputReferences?: Array<DataContent>;
|
|
5903
5920
|
/**
|
|
5904
5921
|
* Whether the model should generate audio alongside the video.
|
|
5905
5922
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1281,7 +1281,7 @@ function detectMediaType({
|
|
|
1281
1281
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1282
1282
|
|
|
1283
1283
|
// src/version.ts
|
|
1284
|
-
var VERSION = true ? "6.0.
|
|
1284
|
+
var VERSION = true ? "6.0.218" : "0.0.0-test";
|
|
1285
1285
|
|
|
1286
1286
|
// src/util/download/download.ts
|
|
1287
1287
|
var download = async ({
|
|
@@ -2812,66 +2812,18 @@ var retryWithExponentialBackoffRespectingRetryHeaders = ({
|
|
|
2812
2812
|
initialDelayInMs = 2e3,
|
|
2813
2813
|
backoffFactor = 2,
|
|
2814
2814
|
abortSignal
|
|
2815
|
-
} = {}) =>
|
|
2815
|
+
} = {}) => (0, import_provider_utils8.retryWithExponentialBackoff)({
|
|
2816
2816
|
maxRetries,
|
|
2817
|
-
|
|
2817
|
+
initialDelayInMs,
|
|
2818
2818
|
backoffFactor,
|
|
2819
|
-
abortSignal
|
|
2819
|
+
abortSignal,
|
|
2820
|
+
shouldRetry: (error) => error instanceof Error && (import_provider27.APICallError.isInstance(error) && error.isRetryable === true || import_gateway3.GatewayError.isInstance(error) && error.isRetryable === true),
|
|
2821
|
+
getDelayInMs: ({ error, exponentialBackoffDelay }) => getRetryDelayInMs({
|
|
2822
|
+
error,
|
|
2823
|
+
exponentialBackoffDelay
|
|
2824
|
+
}),
|
|
2825
|
+
createRetryError: ({ message, reason, errors }) => new RetryError({ message, reason, errors })
|
|
2820
2826
|
});
|
|
2821
|
-
async function _retryWithExponentialBackoff(f, {
|
|
2822
|
-
maxRetries,
|
|
2823
|
-
delayInMs,
|
|
2824
|
-
backoffFactor,
|
|
2825
|
-
abortSignal
|
|
2826
|
-
}, errors = []) {
|
|
2827
|
-
try {
|
|
2828
|
-
return await f();
|
|
2829
|
-
} catch (error) {
|
|
2830
|
-
if ((0, import_provider_utils8.isAbortError)(error)) {
|
|
2831
|
-
throw error;
|
|
2832
|
-
}
|
|
2833
|
-
if (maxRetries === 0) {
|
|
2834
|
-
throw error;
|
|
2835
|
-
}
|
|
2836
|
-
const errorMessage = (0, import_provider_utils8.getErrorMessage)(error);
|
|
2837
|
-
const newErrors = [...errors, error];
|
|
2838
|
-
const tryNumber = newErrors.length;
|
|
2839
|
-
if (tryNumber > maxRetries) {
|
|
2840
|
-
throw new RetryError({
|
|
2841
|
-
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
2842
|
-
reason: "maxRetriesExceeded",
|
|
2843
|
-
errors: newErrors
|
|
2844
|
-
});
|
|
2845
|
-
}
|
|
2846
|
-
if (error instanceof Error && (import_provider27.APICallError.isInstance(error) && error.isRetryable === true || import_gateway3.GatewayError.isInstance(error) && error.isRetryable === true) && tryNumber <= maxRetries) {
|
|
2847
|
-
await (0, import_provider_utils8.delay)(
|
|
2848
|
-
getRetryDelayInMs({
|
|
2849
|
-
error,
|
|
2850
|
-
exponentialBackoffDelay: delayInMs
|
|
2851
|
-
}),
|
|
2852
|
-
{ abortSignal }
|
|
2853
|
-
);
|
|
2854
|
-
return _retryWithExponentialBackoff(
|
|
2855
|
-
f,
|
|
2856
|
-
{
|
|
2857
|
-
maxRetries,
|
|
2858
|
-
delayInMs: backoffFactor * delayInMs,
|
|
2859
|
-
backoffFactor,
|
|
2860
|
-
abortSignal
|
|
2861
|
-
},
|
|
2862
|
-
newErrors
|
|
2863
|
-
);
|
|
2864
|
-
}
|
|
2865
|
-
if (tryNumber === 1) {
|
|
2866
|
-
throw error;
|
|
2867
|
-
}
|
|
2868
|
-
throw new RetryError({
|
|
2869
|
-
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
2870
|
-
reason: "errorNotRetryable",
|
|
2871
|
-
errors: newErrors
|
|
2872
|
-
});
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
2827
|
|
|
2876
2828
|
// src/util/prepare-retries.ts
|
|
2877
2829
|
function prepareRetries({
|
|
@@ -11046,12 +10998,12 @@ function simulateReadableStream({
|
|
|
11046
10998
|
_internal
|
|
11047
10999
|
}) {
|
|
11048
11000
|
var _a22;
|
|
11049
|
-
const
|
|
11001
|
+
const delay = (_a22 = _internal == null ? void 0 : _internal.delay) != null ? _a22 : import_provider_utils31.delay;
|
|
11050
11002
|
let index = 0;
|
|
11051
11003
|
return new ReadableStream({
|
|
11052
11004
|
async pull(controller) {
|
|
11053
11005
|
if (index < chunks.length) {
|
|
11054
|
-
await
|
|
11006
|
+
await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);
|
|
11055
11007
|
controller.enqueue(chunks[index++]);
|
|
11056
11008
|
} else {
|
|
11057
11009
|
controller.close();
|
|
@@ -11791,7 +11743,7 @@ var CHUNKING_REGEXPS = {
|
|
|
11791
11743
|
function smoothStream({
|
|
11792
11744
|
delayInMs = 10,
|
|
11793
11745
|
chunking = "word",
|
|
11794
|
-
_internal: { delay
|
|
11746
|
+
_internal: { delay = import_provider_utils34.delay } = {}
|
|
11795
11747
|
} = {}) {
|
|
11796
11748
|
let detectChunk;
|
|
11797
11749
|
if (chunking != null && typeof chunking === "object" && "segment" in chunking && typeof chunking.segment === "function") {
|
|
@@ -11872,7 +11824,7 @@ function smoothStream({
|
|
|
11872
11824
|
while ((match = detectChunk(buffer)) != null) {
|
|
11873
11825
|
controller.enqueue({ type, text: match, id });
|
|
11874
11826
|
buffer = buffer.slice(match.length);
|
|
11875
|
-
await
|
|
11827
|
+
await delay(delayInMs);
|
|
11876
11828
|
}
|
|
11877
11829
|
}
|
|
11878
11830
|
});
|
|
@@ -11892,6 +11844,8 @@ async function experimental_generateVideo({
|
|
|
11892
11844
|
duration,
|
|
11893
11845
|
fps,
|
|
11894
11846
|
seed,
|
|
11847
|
+
frameImages,
|
|
11848
|
+
inputReferences,
|
|
11895
11849
|
generateAudio,
|
|
11896
11850
|
providerOptions,
|
|
11897
11851
|
maxRetries: maxRetriesArg,
|
|
@@ -11899,7 +11853,7 @@ async function experimental_generateVideo({
|
|
|
11899
11853
|
headers,
|
|
11900
11854
|
download: downloadFn = defaultDownload
|
|
11901
11855
|
}) {
|
|
11902
|
-
var _a22;
|
|
11856
|
+
var _a22, _b;
|
|
11903
11857
|
const model = resolveVideoModel(modelArg);
|
|
11904
11858
|
const headersWithUserAgent = (0, import_provider_utils35.withUserAgentSuffix)(
|
|
11905
11859
|
headers != null ? headers : {},
|
|
@@ -11910,7 +11864,32 @@ async function experimental_generateVideo({
|
|
|
11910
11864
|
abortSignal
|
|
11911
11865
|
});
|
|
11912
11866
|
const { prompt, image } = normalizePrompt2(promptArg);
|
|
11913
|
-
const
|
|
11867
|
+
const normalizedFrameImages = frameImages == null ? void 0 : frameImages.map((frame) => ({
|
|
11868
|
+
image: normalizeImageData(frame.image),
|
|
11869
|
+
frameType: frame.frameType
|
|
11870
|
+
}));
|
|
11871
|
+
const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.map(
|
|
11872
|
+
(reference) => normalizeImageData(reference)
|
|
11873
|
+
);
|
|
11874
|
+
const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? void 0 : normalizedInputReferences;
|
|
11875
|
+
const warnings = [];
|
|
11876
|
+
if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
|
|
11877
|
+
warnings.push({
|
|
11878
|
+
type: "other",
|
|
11879
|
+
message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
|
|
11880
|
+
});
|
|
11881
|
+
}
|
|
11882
|
+
const firstFrameImage = (_a22 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
|
|
11883
|
+
(frame) => frame.frameType === "first_frame"
|
|
11884
|
+
)) == null ? void 0 : _a22.image;
|
|
11885
|
+
if (image != null && firstFrameImage != null) {
|
|
11886
|
+
warnings.push({
|
|
11887
|
+
type: "other",
|
|
11888
|
+
message: "prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image."
|
|
11889
|
+
});
|
|
11890
|
+
}
|
|
11891
|
+
const resolvedImage = firstFrameImage != null ? firstFrameImage : image;
|
|
11892
|
+
const maxVideosPerCallWithDefault = (_b = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _b : 1;
|
|
11914
11893
|
const callCount = Math.ceil(n / maxVideosPerCallWithDefault);
|
|
11915
11894
|
const callVideoCounts = Array.from({ length: callCount }, (_, index) => {
|
|
11916
11895
|
const remaining = n - index * maxVideosPerCallWithDefault;
|
|
@@ -11918,7 +11897,7 @@ async function experimental_generateVideo({
|
|
|
11918
11897
|
});
|
|
11919
11898
|
const results = await Promise.all(
|
|
11920
11899
|
callVideoCounts.map(
|
|
11921
|
-
async (callVideoCount) => retry(
|
|
11900
|
+
async (callVideoCount) => await retry(
|
|
11922
11901
|
() => model.doGenerate({
|
|
11923
11902
|
prompt,
|
|
11924
11903
|
n: callVideoCount,
|
|
@@ -11927,8 +11906,10 @@ async function experimental_generateVideo({
|
|
|
11927
11906
|
duration,
|
|
11928
11907
|
fps,
|
|
11929
11908
|
seed,
|
|
11909
|
+
image: resolvedImage,
|
|
11910
|
+
frameImages: normalizedFrameImages,
|
|
11911
|
+
inputReferences: effectiveInputReferences,
|
|
11930
11912
|
generateAudio,
|
|
11931
|
-
image,
|
|
11932
11913
|
providerOptions: providerOptions != null ? providerOptions : {},
|
|
11933
11914
|
headers: headersWithUserAgent,
|
|
11934
11915
|
abortSignal
|
|
@@ -11937,7 +11918,6 @@ async function experimental_generateVideo({
|
|
|
11937
11918
|
)
|
|
11938
11919
|
);
|
|
11939
11920
|
const videos = [];
|
|
11940
|
-
const warnings = [];
|
|
11941
11921
|
const responses = [];
|
|
11942
11922
|
const providerMetadata = {};
|
|
11943
11923
|
for (const result of results) {
|
|
@@ -12033,56 +12013,49 @@ async function experimental_generateVideo({
|
|
|
12033
12013
|
};
|
|
12034
12014
|
}
|
|
12035
12015
|
function normalizePrompt2(promptArg) {
|
|
12036
|
-
var _a22, _b;
|
|
12037
12016
|
if (typeof promptArg === "string") {
|
|
12038
12017
|
return {
|
|
12039
12018
|
prompt: promptArg,
|
|
12040
12019
|
image: void 0
|
|
12041
12020
|
};
|
|
12042
12021
|
}
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
const bytes = (0, import_provider_utils35.convertBase64ToUint8Array)(dataContent);
|
|
12061
|
-
const mediaType = (_a22 = detectMediaType({
|
|
12062
|
-
data: bytes,
|
|
12063
|
-
signatures: imageMediaTypeSignatures
|
|
12064
|
-
})) != null ? _a22 : "image/png";
|
|
12065
|
-
image = {
|
|
12066
|
-
type: "file",
|
|
12067
|
-
mediaType,
|
|
12068
|
-
data: bytes
|
|
12069
|
-
};
|
|
12070
|
-
}
|
|
12071
|
-
} else if (dataContent instanceof Uint8Array) {
|
|
12072
|
-
const mediaType = (_b = detectMediaType({
|
|
12073
|
-
data: dataContent,
|
|
12074
|
-
signatures: imageMediaTypeSignatures
|
|
12075
|
-
})) != null ? _b : "image/png";
|
|
12076
|
-
image = {
|
|
12022
|
+
return {
|
|
12023
|
+
prompt: promptArg.text,
|
|
12024
|
+
image: promptArg.image != null ? normalizeImageData(promptArg.image) : void 0
|
|
12025
|
+
};
|
|
12026
|
+
}
|
|
12027
|
+
function normalizeImageData(dataContent) {
|
|
12028
|
+
var _a22, _b;
|
|
12029
|
+
if (typeof dataContent === "string") {
|
|
12030
|
+
if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
|
|
12031
|
+
return {
|
|
12032
|
+
type: "url",
|
|
12033
|
+
url: dataContent
|
|
12034
|
+
};
|
|
12035
|
+
}
|
|
12036
|
+
if (dataContent.startsWith("data:")) {
|
|
12037
|
+
const { mediaType, base64Content } = splitDataUrl(dataContent);
|
|
12038
|
+
return {
|
|
12077
12039
|
type: "file",
|
|
12078
|
-
mediaType,
|
|
12079
|
-
data:
|
|
12040
|
+
mediaType: mediaType != null ? mediaType : "image/png",
|
|
12041
|
+
data: (0, import_provider_utils35.convertBase64ToUint8Array)(base64Content != null ? base64Content : "")
|
|
12080
12042
|
};
|
|
12081
12043
|
}
|
|
12044
|
+
const bytes2 = (0, import_provider_utils35.convertBase64ToUint8Array)(dataContent);
|
|
12045
|
+
return {
|
|
12046
|
+
type: "file",
|
|
12047
|
+
mediaType: (_a22 = detectMediaType({
|
|
12048
|
+
data: bytes2,
|
|
12049
|
+
signatures: imageMediaTypeSignatures
|
|
12050
|
+
})) != null ? _a22 : "image/png",
|
|
12051
|
+
data: bytes2
|
|
12052
|
+
};
|
|
12082
12053
|
}
|
|
12054
|
+
const bytes = convertDataContentToUint8Array(dataContent);
|
|
12083
12055
|
return {
|
|
12084
|
-
|
|
12085
|
-
image
|
|
12056
|
+
type: "file",
|
|
12057
|
+
mediaType: (_b = detectMediaType({ data: bytes, signatures: imageMediaTypeSignatures })) != null ? _b : "image/png",
|
|
12058
|
+
data: bytes
|
|
12086
12059
|
};
|
|
12087
12060
|
}
|
|
12088
12061
|
async function invokeModelMaxVideosPerCall(model) {
|