UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

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

200 lines 8.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Seed2Lite = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class Seed2Lite { constructor() { this.description = { displayName: 'Wiro - Seed-V2-Lite Text-to-Image Generator', name: 'seed2Lite', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'Generate visual content with Seed-V2-Lite, a lightweight LLM from ByteDance. Perfect for creati', defaults: { name: 'Wiro - Seed-V2-Lite Text-to-Image Generator', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'wiroApi', required: true, }, ], properties: [ { displayName: 'Input Image URL', name: 'inputImageUrl', type: 'string', default: '', description: 'Optional. Multiple image files separated by semicolon for visual understanding.', }, { displayName: 'Prompt', name: 'prompt', type: 'string', default: '', required: true, description: 'Required', }, { displayName: 'User ID', name: 'user_id', type: 'string', default: '', description: 'Required for chat history. Numeric or string ID.', }, { displayName: 'Session ID', name: 'session_id', type: 'string', default: '', description: 'Required for chat history. Numeric or string ID.', }, { displayName: 'System Instructions', name: 'systemInstructions', type: 'string', default: '', description: 'Optional. System-level instructions for the model.', }, { displayName: 'Temperature', name: 'temperature', type: 'number', default: 0, description: 'Optional. Controls randomness. Range [0, 2]. Default 1', }, { displayName: 'Top P', name: 'topP', type: 'number', default: 0, description: 'Optional. Nucleus sampling threshold. Range [0, 1]. Default 0.7', }, { displayName: 'Frequency Penalty', name: 'frequencyPenalty', type: 'number', default: 0, description: 'Optional. Penalizes repeated tokens by frequency. Range [-2, 2]. Default 0', }, { displayName: 'Presence Penalty', name: 'presencePenalty', type: 'number', default: 0, description: 'Optional. Encourages new topics. Range [-2, 2]. Default 0', }, { displayName: 'Max Completion Tokens', name: 'maxCompletionTokens', type: 'number', default: 0, description: 'Optional. Max output tokens including chain-of-thought. Range [0, 65536]. Default 65536', }, { displayName: 'Reasoning Effort', name: 'reasoningEffort', type: 'options', default: 'high', description: 'Optional. Controls reasoning depth. Default medium', options: [ { name: 'High', value: 'high' }, { name: 'Low', value: 'low' }, { name: 'Medium', value: 'medium' }, { name: 'Minimal', value: 'minimal' }, ], }, { displayName: 'Thinking Type', name: 'thinkingType', type: 'options', default: 'auto', description: 'Optional. Enable/disable deep thinking mode. Default enabled', options: [ { name: 'Auto', value: 'auto' }, { name: 'Disabled', value: 'disabled' }, { name: 'Enabled', value: 'enabled' }, ], }, ], }; } async execute() { const returnData = []; const inputImageUrl = this.getNodeParameter('inputImageUrl', 0, ''); const prompt = this.getNodeParameter('prompt', 0); const user_id = this.getNodeParameter('user_id', 0, ''); const session_id = this.getNodeParameter('session_id', 0, ''); const systemInstructions = this.getNodeParameter('systemInstructions', 0, ''); const temperature = this.getNodeParameter('temperature', 0, 0); const topP = this.getNodeParameter('topP', 0, 0); const frequencyPenalty = this.getNodeParameter('frequencyPenalty', 0, 0); const presencePenalty = this.getNodeParameter('presencePenalty', 0, 0); const maxCompletionTokens = this.getNodeParameter('maxCompletionTokens', 0, 0); const reasoningEffort = this.getNodeParameter('reasoningEffort', 0, ''); const thinkingType = this.getNodeParameter('thinkingType', 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/bytedance/seed-v2-lite', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputImageUrl, prompt, user_id, session_id, systemInstructions, temperature, topP, frequencyPenalty, presencePenalty, maxCompletionTokens, reasoningEffort, thinkingType, }, }); 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, message: '', status: '', }; switch (result) { case '-1': case '-2': case '-3': case '-4': responseJSON.status = 'failed'; break; default: responseJSON.status = 'completed'; responseJSON.message = result !== null && result !== void 0 ? result : ''; } returnData.push({ json: responseJSON, }); return [returnData]; } } exports.Seed2Lite = Seed2Lite; //# sourceMappingURL=Seed2Lite.node.js.map