n8n-nodes-vlm 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -207,23 +207,23 @@ class VLMComplexityWorkflow {
|
|
|
207
207
|
name: 'outputFormat',
|
|
208
208
|
type: 'options',
|
|
209
209
|
options: [
|
|
210
|
-
{
|
|
211
|
-
name: 'Documents Array',
|
|
212
|
-
value: 'documents',
|
|
213
|
-
description: 'Return classified documents in an array',
|
|
214
|
-
},
|
|
215
210
|
{
|
|
216
211
|
name: 'Separate Items',
|
|
217
212
|
value: 'items',
|
|
218
|
-
description: 'Return each document as a separate item',
|
|
213
|
+
description: 'Return each document as a separate item (recommended for binary data)',
|
|
219
214
|
},
|
|
220
215
|
{
|
|
221
216
|
name: 'Original Format',
|
|
222
217
|
value: 'original',
|
|
223
218
|
description: 'Maintain original input structure with classifications added',
|
|
224
219
|
},
|
|
220
|
+
{
|
|
221
|
+
name: 'Documents Array',
|
|
222
|
+
value: 'documents',
|
|
223
|
+
description: 'Return classified documents in an array',
|
|
224
|
+
},
|
|
225
225
|
],
|
|
226
|
-
default: '
|
|
226
|
+
default: 'items',
|
|
227
227
|
description: 'How to format the output',
|
|
228
228
|
},
|
|
229
229
|
],
|
|
@@ -297,24 +297,76 @@ class VLMComplexityWorkflow {
|
|
|
297
297
|
const fieldName = this.getNodeParameter('fieldName', 0);
|
|
298
298
|
for (let i = 0; i < items.length; i++) {
|
|
299
299
|
const fieldData = items[i].json[fieldName];
|
|
300
|
+
const extractedDocs = [];
|
|
300
301
|
if (Array.isArray(fieldData)) {
|
|
301
|
-
|
|
302
|
+
extractedDocs.push(...fieldData);
|
|
302
303
|
}
|
|
303
304
|
else if (fieldData) {
|
|
304
|
-
|
|
305
|
+
extractedDocs.push(fieldData);
|
|
305
306
|
}
|
|
307
|
+
// For each extracted document, also attach binary data if available
|
|
308
|
+
extractedDocs.forEach((doc) => {
|
|
309
|
+
const enhancedDoc = typeof doc === 'object' ? { ...doc } : { content: doc };
|
|
310
|
+
// Extract binary image data from n8n item.binary
|
|
311
|
+
const itemBinary = items[i].binary;
|
|
312
|
+
if (itemBinary) {
|
|
313
|
+
enhancedDoc.metadata = enhancedDoc.metadata || {};
|
|
314
|
+
enhancedDoc.metadata._originalBinary = itemBinary;
|
|
315
|
+
enhancedDoc.metadata._itemIndex = i;
|
|
316
|
+
// Find first image in binary data
|
|
317
|
+
for (const [binaryKey, binaryData] of Object.entries(itemBinary)) {
|
|
318
|
+
const data = binaryData;
|
|
319
|
+
if (data.mimeType && data.mimeType.startsWith('image/')) {
|
|
320
|
+
const base64Data = data.data;
|
|
321
|
+
if (base64Data) {
|
|
322
|
+
enhancedDoc.base64Image = `data:${data.mimeType};base64,${base64Data}`;
|
|
323
|
+
enhancedDoc.metadata._binaryKey = binaryKey;
|
|
324
|
+
this.logger.debug(`Extracted image from binary '${binaryKey}' (${data.mimeType}) for item ${i} (field source)`);
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
documents.push(enhancedDoc);
|
|
331
|
+
});
|
|
306
332
|
}
|
|
307
333
|
}
|
|
308
334
|
else if (documentSource === 'expression') {
|
|
309
335
|
// Extract from expression
|
|
310
336
|
for (let i = 0; i < items.length; i++) {
|
|
311
337
|
const expressionValue = this.getNodeParameter('documentsExpression', i);
|
|
338
|
+
const extractedDocs = [];
|
|
312
339
|
if (Array.isArray(expressionValue)) {
|
|
313
|
-
|
|
340
|
+
extractedDocs.push(...expressionValue);
|
|
314
341
|
}
|
|
315
342
|
else if (expressionValue) {
|
|
316
|
-
|
|
343
|
+
extractedDocs.push(expressionValue);
|
|
317
344
|
}
|
|
345
|
+
// For each extracted document, also attach binary data if available
|
|
346
|
+
extractedDocs.forEach((doc) => {
|
|
347
|
+
const enhancedDoc = typeof doc === 'object' ? { ...doc } : { content: doc };
|
|
348
|
+
// Extract binary image data from n8n item.binary
|
|
349
|
+
const itemBinary = items[i].binary;
|
|
350
|
+
if (itemBinary) {
|
|
351
|
+
enhancedDoc.metadata = enhancedDoc.metadata || {};
|
|
352
|
+
enhancedDoc.metadata._originalBinary = itemBinary;
|
|
353
|
+
enhancedDoc.metadata._itemIndex = i;
|
|
354
|
+
// Find first image in binary data
|
|
355
|
+
for (const [binaryKey, binaryData] of Object.entries(itemBinary)) {
|
|
356
|
+
const data = binaryData;
|
|
357
|
+
if (data.mimeType && data.mimeType.startsWith('image/')) {
|
|
358
|
+
const base64Data = data.data;
|
|
359
|
+
if (base64Data) {
|
|
360
|
+
enhancedDoc.base64Image = `data:${data.mimeType};base64,${base64Data}`;
|
|
361
|
+
enhancedDoc.metadata._binaryKey = binaryKey;
|
|
362
|
+
this.logger.debug(`Extracted image from binary '${binaryKey}' (${data.mimeType}) for item ${i} (expression source)`);
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
documents.push(enhancedDoc);
|
|
369
|
+
});
|
|
318
370
|
}
|
|
319
371
|
}
|
|
320
372
|
if (documents.length === 0) {
|
package/package.json
CHANGED