UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.

152 lines 5.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WanImageSmall = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class WanImageSmall { constructor() { this.description = { displayName: 'Wiro - Wan Image Small', name: 'wanImageSmall', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'Wan-image-small is a highly optimized, resource-efficient AI model that rapidly generates high-', defaults: { name: 'Wiro - Wan Image Small', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'wiroApi', required: true, }, ], properties: [ { displayName: 'Prompt', name: 'prompt', type: 'string', default: '', required: true, description: 'Text input for prompt', }, { displayName: 'Juiced', name: 'juiced', type: 'options', default: 'false', description: 'Select option for juiced', options: [ { name: 'False', value: 'false' }, { name: 'True', value: 'true' }, ], }, { displayName: 'Aspect Ratio', name: 'aspectRatio', type: 'options', default: '1:1', description: 'Select option for aspect ratio', options: [ { name: '1:1', value: '1:1' }, { name: '16:9', value: '16:9' }, { name: '21:9', value: '21:9' }, { name: '3:4', value: '3:4' }, { name: '4:3', value: '4:3' }, { name: '9:16', value: '9:16' }, ], }, { displayName: 'Seed', name: 'seed', type: 'string', default: '', description: 'Random seed. Leave zero to randomize the seed.', }, { displayName: 'Output Format', name: 'outputFormat', type: 'options', default: 'jpg', description: 'Select option for output format', options: [ { name: 'Jpg', value: 'jpg' }, { name: 'Png', value: 'png' }, { name: 'Webp', value: 'webp' }, ], }, { displayName: 'Output Quality', name: 'outputQuality', type: 'string', default: '', description: 'Quality for jpg/webp (1-100)', }, ], }; } async execute() { const returnData = []; const prompt = this.getNodeParameter('prompt', 0); const juiced = this.getNodeParameter('juiced', 0, ''); const aspectRatio = this.getNodeParameter('aspectRatio', 0, ''); const seed = this.getNodeParameter('seed', 0, ''); const outputFormat = this.getNodeParameter('outputFormat', 0, ''); const outputQuality = this.getNodeParameter('outputQuality', 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/pruna/wan-image-small', headers: { ...headers, 'Content-Type': 'application/json', }, body: { prompt, juiced, aspectRatio, seed, outputFormat, outputQuality, }, }); 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.WanImageSmall = WanImageSmall; //# sourceMappingURL=WanImageSmall.node.js.map