@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
186 lines • 7.18 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnimateDiff = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class AnimateDiff {
constructor() {
this.description = {
displayName: 'Wiro - AnimateDiff Text To Video',
name: 'animateDiff',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'It generates a video from the given prompt',
defaults: {
name: 'Wiro - AnimateDiff Text To Video',
},
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
usableAsTool: true,
credentials: [
{
name: 'wiroApi',
required: true,
},
],
properties: [
{
displayName: 'Dreambooth Model',
name: 'selectedModel',
type: 'options',
default: '',
description: 'Select-model-help',
options: [
{ name: '', value: '' },
],
},
{
displayName: 'Dreambooth Model Private',
name: 'selectedModelPrivate',
type: 'options',
default: '',
description: 'Select-model-private-help',
options: [],
},
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
default: '',
required: true,
description: 'Prompt-help',
},
{
displayName: 'Negativeprompt',
name: 'negativePrompt',
type: 'string',
default: '',
description: 'Negativeprompt-help',
},
{
displayName: 'Lora Type',
name: 'loraType',
type: 'options',
default: 'FILE:169578',
required: true,
description: 'Lora-type-help',
options: [
{ name: 'PanLeft', value: 'FILE:169578' },
{ name: 'PanRight', value: 'FILE:169579' },
{ name: 'RollingAnticlockwise', value: 'FILE:169580' },
{ name: 'RollingClockwise', value: 'FILE:169581' },
{ name: 'TiltDown', value: 'FILE:169582' },
{ name: 'TiltUp', value: 'FILE:169583' },
{ name: 'ZoomIn', value: 'FILE:169584' },
{ name: 'ZoomOut', value: 'FILE:169585' },
],
},
{
displayName: 'Framenumber',
name: 'frameNumber',
type: 'number',
default: 0,
description: 'Framenumber-help',
},
{
displayName: 'Inferencesteps',
name: 'steps',
type: 'number',
default: 0,
description: 'Inferencesteps-help',
},
{
displayName: 'Seed',
name: 'seed',
type: 'string',
default: '',
description: 'Seed-help',
},
{
displayName: 'Width',
name: 'width',
type: 'number',
default: 0,
description: 'Width-help',
},
{
displayName: 'Height',
name: 'height',
type: 'number',
default: 0,
description: 'Height-help',
},
],
};
}
async execute() {
const returnData = [];
const selectedModel = this.getNodeParameter('selectedModel', 0, '');
const selectedModelPrivate = this.getNodeParameter('selectedModelPrivate', 0, '');
const prompt = this.getNodeParameter('prompt', 0);
const negativePrompt = this.getNodeParameter('negativePrompt', 0, '');
const loraType = this.getNodeParameter('loraType', 0);
const frameNumber = this.getNodeParameter('frameNumber', 0, 0);
const steps = this.getNodeParameter('steps', 0, 0);
const seed = this.getNodeParameter('seed', 0, '');
const width = this.getNodeParameter('width', 0, 0);
const height = this.getNodeParameter('height', 0, 0);
const credentials = await this.getCredentials('wiroApi');
const apiKey = credentials.apiKey;
const apiSecret = credentials.apiSecret;
const headers = (0, auth_1.generateWiroAuthHeaders)(apiKey, apiSecret);
const response = await this.helpers.httpRequest({
method: 'POST',
url: 'https://api.wiro.ai/v1/Run/wiro/animate-diff',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
selectedModel,
selectedModelPrivate,
prompt,
negativePrompt,
loraType,
frameNumber,
steps,
seed,
width,
height,
},
});
if (!(response === null || response === void 0 ? void 0 : response.taskid) || !(response === null || response === void 0 ? void 0 : response.socketaccesstoken)) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
message: 'Wiro API did not return a valid task ID or socket access token ' +
JSON.stringify(response),
});
}
const taskid = response.taskid;
const socketaccesstoken = response.socketaccesstoken;
const result = await polling_1.pollTaskUntilComplete.call(this, socketaccesstoken, headers);
const responseJSON = {
taskid: taskid,
url: '',
status: '',
};
switch (result) {
case '-1':
case '-2':
case '-3':
case '-4':
responseJSON.status = 'failed';
break;
default:
responseJSON.status = 'completed';
responseJSON.url = result !== null && result !== void 0 ? result : '';
}
returnData.push({
json: responseJSON,
});
return [returnData];
}
}
exports.AnimateDiff = AnimateDiff;
//# sourceMappingURL=AnimateDiff.node.js.map