🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ai

Package Overview
Dependencies
Maintainers
5
Versions
1312
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai - npm Package Compare versions

Comparing version
7.0.7
to
7.0.8
+4
-4
package.json
{
"name": "ai",
"version": "7.0.7",
"version": "7.0.8",
"type": "module",

@@ -45,5 +45,5 @@ "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",

"dependencies": {
"@ai-sdk/gateway": "4.0.5",
"@ai-sdk/provider": "4.0.0",
"@ai-sdk/provider-utils": "5.0.1"
"@ai-sdk/gateway": "4.0.6",
"@ai-sdk/provider": "4.0.1",
"@ai-sdk/provider-utils": "5.0.2"
},

@@ -50,0 +50,0 @@ "devDependencies": {

@@ -5,2 +5,4 @@ import type {

Experimental_VideoModelV4File,
Experimental_VideoModelV4FrameImage,
Experimental_VideoModelV4FrameType,
SharedV4ProviderMetadata,

@@ -30,2 +32,3 @@ } from '@ai-sdk/provider';

import { splitDataUrl } from '../prompt/split-data-url';
import { convertDataContentToUint8Array } from '../prompt/data-content';

@@ -50,2 +53,4 @@ export type GenerateVideoPrompt =

* @param seed - Seed for the video generation.
* @param frameImages - Role-tagged image inputs for image-to-video and first-last-frame generation.
* @param inputReferences - Reference image inputs for reference-to-video generation.
* @param generateAudio - Whether the model should generate audio alongside the video.

@@ -72,2 +77,4 @@ * @param providerOptions - Additional provider-specific options that are passed through to the provider

seed,
frameImages,
inputReferences,
generateAudio,

@@ -126,2 +133,22 @@ providerOptions,

/**
* Role-tagged image inputs for image-to-video and first-last-frame generation.
*/
frameImages?: Array<{
/**
* The image for this frame.
*/
image: DataContent;
/**
* Which frame this image represents.
*/
frameType: Experimental_VideoModelV4FrameType;
}>;
/**
* Reference image inputs for reference-to-video generation.
*/
inputReferences?: Array<DataContent>;
/**
* Whether the model should generate audio alongside the video.

@@ -180,2 +207,51 @@ */

const normalizedFrameImages:
| Array<Experimental_VideoModelV4FrameImage>
| undefined = frameImages?.map(frame => ({
image: normalizeImageData(frame.image),
frameType: frame.frameType,
}));
const normalizedInputReferences:
| Array<Experimental_VideoModelV4File>
| undefined = inputReferences?.map(reference =>
normalizeImageData(reference),
);
const effectiveInputReferences =
normalizedFrameImages != null && normalizedFrameImages.length > 0
? undefined
: normalizedInputReferences;
const warnings: Array<Warning> = [];
if (
normalizedFrameImages != null &&
normalizedFrameImages.length > 0 &&
normalizedInputReferences != null &&
normalizedInputReferences.length > 0
) {
warnings.push({
type: 'other',
message:
'inputReferences were ignored because frameImages were provided; ' +
'frameImages and inputReferences cannot be combined.',
});
}
const firstFrameImage = normalizedFrameImages?.find(
frame => frame.frameType === 'first_frame',
)?.image;
if (image != null && firstFrameImage != null) {
warnings.push({
type: 'other',
message:
'prompt.image was ignored because a first_frame frameImage was provided; ' +
'the first_frame frameImage takes precedence as the start image.',
});
}
const resolvedImage = firstFrameImage ?? image;
const maxVideosPerCallWithDefault =

@@ -203,4 +279,6 @@ maxVideosPerCall ?? (await invokeModelMaxVideosPerCall(model)) ?? 1;

seed,
image: resolvedImage,
frameImages: normalizedFrameImages,
inputReferences: effectiveInputReferences,
generateAudio,
image,
providerOptions: providerOptions ?? {},

@@ -216,3 +294,2 @@ headers: headersWithUserAgent,

const videos: Array<GeneratedFile> = [];
const warnings: Array<Warning> = [];
const responses: Array<VideoModelResponseMetadata> = [];

@@ -353,55 +430,51 @@ const providerMetadata: SharedV4ProviderMetadata = {};

let image: Experimental_VideoModelV4File | undefined;
return {
prompt: promptArg.text,
image:
promptArg.image != null ? normalizeImageData(promptArg.image) : undefined,
};
}
if (promptArg.image != null) {
const dataContent = promptArg.image;
/**
* Normalizes a {@link DataContent} image into a {@link Experimental_VideoModelV4File}.
* Accepts a URL string, a data URL, a base64 string, or binary image data.
*/
function normalizeImageData(
dataContent: DataContent,
): Experimental_VideoModelV4File {
if (typeof dataContent === 'string') {
if (
dataContent.startsWith('http://') ||
dataContent.startsWith('https://')
) {
return {
type: 'url',
url: dataContent,
};
}
if (typeof dataContent === 'string') {
if (
dataContent.startsWith('http://') ||
dataContent.startsWith('https://')
) {
image = {
type: 'url',
url: dataContent,
};
} else if (dataContent.startsWith('data:')) {
const { mediaType, base64Content } = splitDataUrl(dataContent);
image = {
type: 'file',
mediaType: mediaType ?? 'image/png',
data: convertBase64ToUint8Array(base64Content ?? ''),
};
} else {
const bytes = convertBase64ToUint8Array(dataContent);
const mediaType =
detectMediaType({
data: bytes,
topLevelType: 'image',
}) ?? 'image/png';
image = {
type: 'file',
mediaType,
data: bytes,
};
}
} else if (dataContent instanceof Uint8Array) {
const mediaType =
detectMediaType({
data: dataContent,
topLevelType: 'image',
}) ?? 'image/png';
image = {
if (dataContent.startsWith('data:')) {
const { mediaType, base64Content } = splitDataUrl(dataContent);
return {
type: 'file',
mediaType,
data: dataContent,
mediaType: mediaType ?? 'image/png',
data: convertBase64ToUint8Array(base64Content ?? ''),
};
}
const bytes = convertBase64ToUint8Array(dataContent);
return {
type: 'file',
mediaType:
detectMediaType({ data: bytes, topLevelType: 'image' }) ?? 'image/png',
data: bytes,
};
}
const bytes = convertDataContentToUint8Array(dataContent);
return {
prompt: promptArg.text,
image,
type: 'file',
mediaType:
detectMediaType({ data: bytes, topLevelType: 'image' }) ?? 'image/png',
data: bytes,
};

@@ -408,0 +481,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet