first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
Vendored
+102
@@ -0,0 +1,102 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from 'n8n-workflow';
|
||||
|
||||
import { baseAnalyze } from '../../helpers/baseAnalyze';
|
||||
import { modelRLC } from '../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
modelRLC('modelSearch'),
|
||||
{
|
||||
displayName: 'Text Input',
|
||||
name: 'text',
|
||||
type: 'string',
|
||||
placeholder: "e.g. What's in this video?",
|
||||
default: "What's in this video?",
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Input Type',
|
||||
name: 'inputType',
|
||||
type: 'options',
|
||||
default: 'url',
|
||||
options: [
|
||||
{
|
||||
name: 'Video URL(s)',
|
||||
value: 'url',
|
||||
},
|
||||
{
|
||||
name: 'Binary File(s)',
|
||||
value: 'binary',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'URL(s)',
|
||||
name: 'videoUrls',
|
||||
type: 'string',
|
||||
placeholder: 'e.g. https://example.com/video.mp4',
|
||||
description: 'URL(s) of the video(s) to analyze, multiple URLs can be added separated by comma',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
inputType: ['url'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Input Data Field Name(s)',
|
||||
name: 'binaryPropertyName',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
placeholder: 'e.g. data',
|
||||
hint: 'The name of the input field containing the binary file data to be processed',
|
||||
description:
|
||||
'Name of the binary field(s) which contains the video(s), seperate multiple field names with commas',
|
||||
displayOptions: {
|
||||
show: {
|
||||
inputType: ['binary'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Simplify Output',
|
||||
name: 'simplify',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to simplify the response or not',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
placeholder: 'Add Option',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Length of Description (Max Tokens)',
|
||||
description: 'Fewer tokens will result in shorter, less detailed video description',
|
||||
name: 'maxOutputTokens',
|
||||
type: 'number',
|
||||
default: 300,
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
operation: ['analyze'],
|
||||
resource: ['video'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
|
||||
return await baseAnalyze.call(this, i, 'videoUrls', 'video/mp4');
|
||||
}
|
||||
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from 'n8n-workflow';
|
||||
|
||||
import { downloadFile } from '../../helpers/utils';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'URL',
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
placeholder: 'e.g. https://generativelanguage.googleapis.com/v1beta/files/abcdefg:download',
|
||||
description: 'The URL from Google Gemini API to download the video from',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
placeholder: 'Add Option',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Put Output in Field',
|
||||
name: 'binaryPropertyOutput',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
hint: 'The name of the output field to put the binary file data in',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
operation: ['download'],
|
||||
resource: ['video'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
|
||||
const url = this.getNodeParameter('url', i, '') as string;
|
||||
const binaryPropertyOutput = this.getNodeParameter(
|
||||
'options.binaryPropertyOutput',
|
||||
i,
|
||||
'data',
|
||||
) as string;
|
||||
const credentials = await this.getCredentials('googlePalmApi');
|
||||
const { fileContent, mimeType } = await downloadFile.call(this, url, 'video/mp4', {
|
||||
key: credentials.apiKey as string,
|
||||
});
|
||||
const binaryData = await this.helpers.prepareBinaryData(fileContent, 'video.mp4', mimeType);
|
||||
return [
|
||||
{
|
||||
binary: { [binaryPropertyOutput]: binaryData },
|
||||
json: {
|
||||
...binaryData,
|
||||
data: undefined,
|
||||
},
|
||||
pairedItem: { item: i },
|
||||
},
|
||||
];
|
||||
}
|
||||
Vendored
+212
@@ -0,0 +1,212 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
||||
import { NodeOperationError, updateDisplayOptions } from 'n8n-workflow';
|
||||
|
||||
import type { VeoResponse } from '../../helpers/interfaces';
|
||||
import { downloadFile } from '../../helpers/utils';
|
||||
import { apiRequest } from '../../transport';
|
||||
import { modelRLC } from '../descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
modelRLC('videoGenerationModelSearch'),
|
||||
{
|
||||
displayName: 'Prompt',
|
||||
name: 'prompt',
|
||||
type: 'string',
|
||||
placeholder: 'e.g. Panning wide shot of a calico kitten sleeping in the sunshine',
|
||||
description: 'A text description of the desired video',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Return As',
|
||||
name: 'returnAs',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Video',
|
||||
value: 'video',
|
||||
},
|
||||
{
|
||||
name: 'URL',
|
||||
value: 'url',
|
||||
},
|
||||
],
|
||||
description:
|
||||
'Whether to return the video as a binary file or a URL that can be used to download the video later',
|
||||
default: 'video',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
placeholder: 'Add Option',
|
||||
type: 'collection',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Number of Videos',
|
||||
name: 'sampleCount',
|
||||
type: 'number',
|
||||
default: 1,
|
||||
description: 'How many videos to generate',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 4,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Duration (Seconds)',
|
||||
name: 'durationSeconds',
|
||||
type: 'number',
|
||||
default: 8,
|
||||
description: 'Length of the generated video in seconds. Supported only by certain models.',
|
||||
typeOptions: {
|
||||
minValue: 5,
|
||||
maxValue: 8,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Aspect Ratio',
|
||||
name: 'aspectRatio',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Widescreen (16:9)',
|
||||
value: '16:9',
|
||||
description: 'Most common aspect ratio for televisions and monitors',
|
||||
},
|
||||
{
|
||||
name: 'Portrait (9:16)',
|
||||
value: '9:16',
|
||||
description: 'Popular for short-form videos like YouTube Shorts',
|
||||
},
|
||||
],
|
||||
default: '16:9',
|
||||
},
|
||||
{
|
||||
displayName: 'Person Generation',
|
||||
name: 'personGeneration',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: "Don't Allow",
|
||||
value: 'dont_allow',
|
||||
description: 'Prevent generation of people in the video',
|
||||
},
|
||||
{
|
||||
name: 'Allow Adult',
|
||||
value: 'allow_adult',
|
||||
description: 'Allow generation of adult people in the video',
|
||||
},
|
||||
{
|
||||
name: 'Allow All',
|
||||
value: 'allow_all',
|
||||
description: 'Allow generation of all people in the video',
|
||||
},
|
||||
],
|
||||
default: 'dont_allow',
|
||||
},
|
||||
{
|
||||
displayName: 'Put Output in Field',
|
||||
name: 'binaryPropertyOutput',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
hint: 'The name of the output field to put the binary file data in',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
operation: ['generate'],
|
||||
resource: ['video'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
|
||||
const model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;
|
||||
const prompt = this.getNodeParameter('prompt', i, '') as string;
|
||||
const returnAs = this.getNodeParameter('returnAs', i, 'video');
|
||||
const options = this.getNodeParameter('options', i, {});
|
||||
const binaryPropertyOutput = this.getNodeParameter(
|
||||
'options.binaryPropertyOutput',
|
||||
i,
|
||||
'data',
|
||||
) as string;
|
||||
const credentials = await this.getCredentials('googlePalmApi');
|
||||
|
||||
if (!model.includes('veo')) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Model ${model} is not supported for video generation. Please use a Veo model`,
|
||||
{
|
||||
description: 'Video generation is only supported by Veo models',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const body = {
|
||||
instances: [
|
||||
{
|
||||
prompt,
|
||||
},
|
||||
],
|
||||
parameters: {
|
||||
aspectRatio: options.aspectRatio,
|
||||
personGeneration: options.personGeneration,
|
||||
sampleCount: options.sampleCount ?? 1,
|
||||
durationSeconds: options.durationSeconds,
|
||||
},
|
||||
};
|
||||
let response = (await apiRequest.call(this, 'POST', `/v1beta/${model}:predictLongRunning`, {
|
||||
body,
|
||||
})) as VeoResponse;
|
||||
|
||||
while (!response.done) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
response = (await apiRequest.call(this, 'GET', `/v1beta/${response.name}`)) as VeoResponse;
|
||||
}
|
||||
|
||||
if (response.error) {
|
||||
throw new NodeOperationError(this.getNode(), response.error.message, {
|
||||
description: 'Error generating video',
|
||||
});
|
||||
}
|
||||
|
||||
if (returnAs === 'video') {
|
||||
const promises = response.response.generateVideoResponse.generatedSamples.map(
|
||||
async (sample) => {
|
||||
const { fileContent, mimeType } = await downloadFile.call(
|
||||
this,
|
||||
sample.video.uri,
|
||||
'video/mp4',
|
||||
{
|
||||
key: credentials.apiKey as string,
|
||||
},
|
||||
);
|
||||
const binaryData = await this.helpers.prepareBinaryData(fileContent, 'video.mp4', mimeType);
|
||||
return {
|
||||
binary: { [binaryPropertyOutput]: binaryData },
|
||||
json: {
|
||||
...binaryData,
|
||||
data: undefined,
|
||||
},
|
||||
pairedItem: { item: i },
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
return await Promise.all(promises);
|
||||
} else {
|
||||
return response.response.generateVideoResponse.generatedSamples.map((sample) => ({
|
||||
json: {
|
||||
url: sample.video.uri,
|
||||
},
|
||||
pairedItem: { item: i },
|
||||
}));
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as analyze from './analyze.operation';
|
||||
import * as download from './download.operation';
|
||||
import * as generate from './generate.operation';
|
||||
|
||||
export { analyze, download, generate };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Analyze Video',
|
||||
value: 'analyze',
|
||||
action: 'Analyze video',
|
||||
description: 'Take in videos and answer questions about them',
|
||||
},
|
||||
{
|
||||
name: 'Generate a Video',
|
||||
value: 'generate',
|
||||
action: 'Generate a video',
|
||||
description: 'Creates a video from a text prompt',
|
||||
},
|
||||
{
|
||||
name: 'Download Video',
|
||||
value: 'download',
|
||||
action: 'Download a video',
|
||||
description: 'Download a generated video from the Google Gemini API using a URL',
|
||||
},
|
||||
],
|
||||
default: 'generate',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['video'],
|
||||
},
|
||||
},
|
||||
},
|
||||
...analyze.description,
|
||||
...download.description,
|
||||
...generate.description,
|
||||
];
|
||||
Reference in New Issue
Block a user