@n8n/n8n-nodes-langchain
Version:
94 lines • 3.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.h3VideoProperties = exports.H3_MODEL = void 0;
exports.assertH3Prompt = assertH3Prompt;
exports.prepareVideoOutput = prepareVideoOutput;
const n8n_workflow_1 = require("n8n-workflow");
exports.H3_MODEL = 'MiniMax-H3';
exports.h3VideoProperties = [
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
typeOptions: {
rows: 4,
},
default: '',
required: true,
description: 'Text description of the video (max 7000 characters)',
placeholder: 'A subject moves naturally through the scene',
displayOptions: {
show: {
modelId: [exports.H3_MODEL],
'@version': [{ _cnd: { gte: 1.1 } }],
},
},
},
{
displayName: 'Duration (Seconds)',
name: 'h3Duration',
type: 'options',
options: Array.from({ length: 12 }, (_, index) => {
const duration = index + 4;
return { name: `${duration} Seconds`, value: duration };
}),
default: 5,
description: 'Duration of the generated video',
displayOptions: {
show: {
modelId: [exports.H3_MODEL],
'@version': [{ _cnd: { gte: 1.1 } }],
},
},
},
{
displayName: 'Resolution',
name: 'h3Resolution',
type: 'options',
options: [
{ name: '768P', value: '768P' },
{ name: '2K', value: '2K' },
],
default: '2K',
description: 'Resolution of the generated video',
displayOptions: {
show: {
modelId: [exports.H3_MODEL],
'@version': [{ _cnd: { gte: 1.1 } }],
},
},
},
];
function assertH3Prompt(executeFunctions, prompt) {
if (!prompt.trim()) {
throw new n8n_workflow_1.NodeOperationError(executeFunctions.getNode(), 'Prompt is required for MiniMax-H3 video generation');
}
}
async function prepareVideoOutput(executeFunctions, itemIndex, result, downloadVideo) {
const json = {
videoUrl: result.videoUrl,
taskId: result.taskId,
};
if (result.fileId)
json.fileId = result.fileId;
if (!downloadVideo) {
return [{ json, pairedItem: { item: itemIndex } }];
}
const response = await executeFunctions.helpers.httpRequest({
method: 'GET',
url: result.videoUrl,
encoding: 'arraybuffer',
returnFullResponse: true,
});
const contentType = response.headers?.['content-type'] || 'video/mp4';
const fileContent = Buffer.from(response.body);
const binaryData = await executeFunctions.helpers.prepareBinaryData(fileContent, 'video.mp4', contentType);
return [
{
binary: { data: binaryData },
json,
pairedItem: { item: itemIndex },
},
];
}
//# sourceMappingURL=helpers.js.map