n8n-nodes-vlm 2.0.1 → 2.0.3

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.
@@ -263,10 +263,34 @@ class VLMComplexityWorkflow {
263
263
  let documents = [];
264
264
  if (documentSource === 'items') {
265
265
  // Use all items as documents
266
- documents = items.map((item, index) => ({
267
- pageContent: JSON.stringify(item.json),
268
- metadata: { _itemIndex: index },
269
- }));
266
+ documents = items.map((item, index) => {
267
+ const doc = {
268
+ pageContent: JSON.stringify(item.json),
269
+ metadata: {
270
+ _itemIndex: index,
271
+ _originalBinary: item.binary, // Preserve original binary data
272
+ },
273
+ };
274
+ // Extract binary image data from n8n item.binary
275
+ if (item.binary) {
276
+ // Find first image in binary data
277
+ for (const [binaryKey, binaryData] of Object.entries(item.binary)) {
278
+ const data = binaryData;
279
+ if (data.mimeType && data.mimeType.startsWith('image/')) {
280
+ // n8n stores binary data as base64 in data.data
281
+ const base64Data = data.data;
282
+ // Add base64 image with data URI format
283
+ if (base64Data) {
284
+ doc.base64Image = `data:${data.mimeType};base64,${base64Data}`;
285
+ doc.metadata._binaryKey = binaryKey; // Remember which binary key was used
286
+ this.logger.debug(`Extracted image from binary '${binaryKey}' (${data.mimeType}) for item ${index}`);
287
+ break; // Use first image found
288
+ }
289
+ }
290
+ }
291
+ }
292
+ return doc;
293
+ });
270
294
  }
271
295
  else if (documentSource === 'field') {
272
296
  // Extract from field
@@ -312,7 +336,19 @@ class VLMComplexityWorkflow {
312
336
  // Format output based on outputFormat option
313
337
  if (outputFormat === 'items') {
314
338
  // Return each document as a separate item
315
- return [classifiedDocs.map((doc) => ({ json: doc }))];
339
+ return [
340
+ classifiedDocs.map((doc) => {
341
+ const outputItem = { json: doc };
342
+ // Restore original binary data if it was preserved
343
+ if (doc.metadata && doc.metadata._originalBinary) {
344
+ outputItem.binary = doc.metadata._originalBinary;
345
+ // Clean up internal metadata from output JSON
346
+ delete doc.metadata._originalBinary;
347
+ delete doc.metadata._binaryKey;
348
+ }
349
+ return outputItem;
350
+ }),
351
+ ];
316
352
  }
317
353
  else if (outputFormat === 'original') {
318
354
  // Maintain original structure but add classifications
@@ -321,6 +357,7 @@ class VLMComplexityWorkflow {
321
357
  ...item.json,
322
358
  _classifications: classifiedDocs,
323
359
  },
360
+ binary: item.binary, // Preserve original binaries
324
361
  }));
325
362
  return [outputItems];
326
363
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-vlm",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Vision-Language Models for n8n - Lightweight specialized VLMs for document analysis and classification",
5
5
  "main": "index.js",
6
6
  "author": "Gabriel BRUMENT",
@@ -25,7 +25,10 @@
25
25
  "dev": "tsc --watch",
26
26
  "lint": "eslint . --ext .ts",
27
27
  "lint:fix": "eslint . --ext .ts --fix",
28
+ "lint-staged": "lint-staged",
28
29
  "test": "jest",
30
+ "test:pre-commit": "jest --bail --findRelatedTests",
31
+ "build:check": "tsc --noEmit",
29
32
  "format": "prettier --write \"**/*.{ts,js,json,md}\"",
30
33
  "format:check": "prettier --check \"**/*.{ts,js,json,md}\"",
31
34
  "prepare": "cd .. && husky custom-nodes/.husky"
@@ -50,6 +53,8 @@
50
53
  "credentials": []
51
54
  },
52
55
  "devDependencies": {
56
+ "@commitlint/cli": "^20.1.0",
57
+ "@commitlint/config-conventional": "^20.0.0",
53
58
  "@types/jest": "^29.0.0",
54
59
  "@types/node": "^18.0.0",
55
60
  "@typescript-eslint/eslint-plugin": "^5.0.0",