n8n-nodes-vlm 2.0.3 → 2.0.4
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.
|
@@ -338,32 +338,65 @@ class VLMComplexityWorkflow {
|
|
|
338
338
|
// Return each document as a separate item
|
|
339
339
|
return [
|
|
340
340
|
classifiedDocs.map((doc) => {
|
|
341
|
-
|
|
341
|
+
// Flatten structure for better n8n usability
|
|
342
|
+
const flattenedJson = {
|
|
343
|
+
// Classification results (top level for visibility)
|
|
344
|
+
complexityClass: doc._complexityClass,
|
|
345
|
+
complexityConfidence: doc._complexityConfidence,
|
|
346
|
+
processingTime: doc._processingTime,
|
|
347
|
+
modelUsed: doc._modelUsed,
|
|
348
|
+
// Document content
|
|
349
|
+
content: doc.pageContent,
|
|
350
|
+
// Original metadata (if any)
|
|
351
|
+
...(doc.metadata && doc.metadata._itemIndex !== undefined ? { itemIndex: doc.metadata._itemIndex } : {}),
|
|
352
|
+
...(doc._originalIndex !== undefined ? { originalIndex: doc._originalIndex } : {}),
|
|
353
|
+
};
|
|
354
|
+
const outputItem = { json: flattenedJson };
|
|
342
355
|
// Restore original binary data if it was preserved
|
|
343
356
|
if (doc.metadata && doc.metadata._originalBinary) {
|
|
344
357
|
outputItem.binary = doc.metadata._originalBinary;
|
|
345
|
-
// Clean up internal metadata from output JSON
|
|
346
|
-
delete doc.metadata._originalBinary;
|
|
347
|
-
delete doc.metadata._binaryKey;
|
|
348
358
|
}
|
|
349
359
|
return outputItem;
|
|
350
360
|
}),
|
|
351
361
|
];
|
|
352
362
|
}
|
|
353
363
|
else if (outputFormat === 'original') {
|
|
354
|
-
// Maintain original structure but add
|
|
355
|
-
const outputItems = items.map((item) =>
|
|
356
|
-
|
|
364
|
+
// Maintain original structure but add flattened classification metadata
|
|
365
|
+
const outputItems = items.map((item, index) => {
|
|
366
|
+
// Find classification for this item
|
|
367
|
+
const itemClassification = classifiedDocs.find((doc) => { var _a; return ((_a = doc.metadata) === null || _a === void 0 ? void 0 : _a._itemIndex) === index || doc._originalIndex === index; });
|
|
368
|
+
const enhancedJson = {
|
|
357
369
|
...item.json,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
370
|
+
};
|
|
371
|
+
// Add classification metadata at top level
|
|
372
|
+
if (itemClassification) {
|
|
373
|
+
enhancedJson.complexityClass = itemClassification._complexityClass;
|
|
374
|
+
enhancedJson.complexityConfidence = itemClassification._complexityConfidence;
|
|
375
|
+
enhancedJson.processingTime = itemClassification._processingTime;
|
|
376
|
+
enhancedJson.modelUsed = itemClassification._modelUsed;
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
json: enhancedJson,
|
|
380
|
+
binary: item.binary, // Preserve original binaries
|
|
381
|
+
};
|
|
382
|
+
});
|
|
362
383
|
return [outputItems];
|
|
363
384
|
}
|
|
364
385
|
else {
|
|
365
|
-
// Default: return documents array
|
|
366
|
-
|
|
386
|
+
// Default: return documents array with flattened structure
|
|
387
|
+
const flattenedDocs = classifiedDocs.map((doc) => {
|
|
388
|
+
var _a;
|
|
389
|
+
return ({
|
|
390
|
+
complexityClass: doc._complexityClass,
|
|
391
|
+
complexityConfidence: doc._complexityConfidence,
|
|
392
|
+
processingTime: doc._processingTime,
|
|
393
|
+
modelUsed: doc._modelUsed,
|
|
394
|
+
content: doc.pageContent,
|
|
395
|
+
itemIndex: (_a = doc.metadata) === null || _a === void 0 ? void 0 : _a._itemIndex,
|
|
396
|
+
originalIndex: doc._originalIndex,
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
return [[{ json: { documents: flattenedDocs } }]];
|
|
367
400
|
}
|
|
368
401
|
}
|
|
369
402
|
catch (error) {
|
package/package.json
CHANGED