@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
154 lines • 6.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FluxKontextMaxMulti = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class FluxKontextMaxMulti {
constructor() {
this.description = {
displayName: 'Wiro - Flux Kontext Max Multi',
name: 'fluxKontextMaxMulti',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'An experimental multi-image approach to a premium text-to-image editing model, designed to maxi',
defaults: {
name: 'Wiro - Flux Kontext Max Multi',
},
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
usableAsTool: true,
credentials: [
{
name: 'wiroApi',
required: true,
},
],
properties: [
{
displayName: 'Image URL',
name: 'inputImageUrl',
type: 'string',
default: '',
description: 'Image to use as reference. Must be jpeg, png.',
},
{
displayName: 'Image Second URL',
name: 'inputImage2Url',
type: 'string',
default: '',
description: 'Image to use as reference. Must be jpeg, png.',
},
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
default: '',
description: 'Text prompt for image generation',
},
{
displayName: 'Prompt Upsampling',
name: 'promptUpsampling',
type: 'options',
default: 'false',
description: 'Whether to perform upsampling on the prompt. If active, automatically modifies the prompt for more creative generation.',
options: [
{ name: 'NO', value: 'false' },
{ name: 'YES', value: 'true' },
],
},
{
displayName: 'Safety Tolerance',
name: 'safetyTolerance',
type: 'options',
default: '2',
description: 'Tolerance level for input and output moderation. Between 0 and 6, 0 being most strict, 6 being least strict.',
options: [
{ name: '2', value: '2' },
],
},
{
displayName: 'Seed',
name: 'seed',
type: 'string',
default: '',
description: 'Seed-help',
},
{
displayName: 'Output Format',
name: 'outputFormat',
type: 'options',
default: 'jpeg',
description: 'Output format for the generated image. Can be \'jpeg\' or \'png\'.',
options: [
{ name: 'Jpeg', value: 'jpeg' },
{ name: 'Png', value: 'png' },
],
},
],
};
}
async execute() {
const returnData = [];
const inputImageUrl = this.getNodeParameter('inputImageUrl', 0, '');
const inputImage2Url = this.getNodeParameter('inputImage2Url', 0, '');
const prompt = this.getNodeParameter('prompt', 0, '');
const promptUpsampling = this.getNodeParameter('promptUpsampling', 0, '');
const safetyTolerance = this.getNodeParameter('safetyTolerance', 0, '');
const seed = this.getNodeParameter('seed', 0, '');
const outputFormat = this.getNodeParameter('outputFormat', 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/wiroai/flux-kontext-max-multi',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
inputImageUrl,
inputImage2Url,
prompt,
promptUpsampling,
safetyTolerance,
seed,
outputFormat,
},
});
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.FluxKontextMaxMulti = FluxKontextMaxMulti;
//# sourceMappingURL=FluxKontextMaxMulti.node.js.map