Spaces:
Runtime error
Runtime error
| { | |
| "name": "Antigravity Image Research Extractor", | |
| "nodes": [ | |
| { | |
| "parameters": { | |
| "path": "C:/Users/Nauti/Desktop/LOGOS CURSOR/LOGOS Notes", | |
| "fileExtensions": "jpg,jpeg,png,pdf,heic", | |
| "options": { | |
| "recurse": true | |
| } | |
| }, | |
| "id": "image_scanner", | |
| "name": "Scan Images (Notes)", | |
| "type": "n8n-nodes-base.readFilesFromFolder", | |
| "position": [ | |
| 250, | |
| 300 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "jsCode": "// ROUTER: Classify images for specialized analysis\nconst images = items.map(item => {\n const fileName = item.json.fileName;\n const fileSize = item.json.size || 0;\n \n let taskType = 'general_vision';\n let priority = 1;\n \n // Route by filename patterns and size\n if (fileName.includes('diagram') || fileName.includes('sketch')) {\n taskType = 'diagram_analysis';\n priority = 3;\n } else if (fileName.includes('note') || fileName.includes('handwritten')) {\n taskType = 'handwriting_ocr';\n priority = 2;\n } else if (fileName.includes('ui') || fileName.includes('interface')) {\n taskType = 'ui_analysis';\n priority = 3;\n } else if (fileSize < 500000) {\n taskType = 'handwriting_ocr'; // Smaller files likely notes\n priority = 2;\n } else {\n taskType = 'diagram_analysis'; // Larger files likely detailed diagrams\n priority = 3;\n }\n \n return {\n json: {\n fileName,\n taskType,\n priority,\n fullPath: item.json.directory + '/' + fileName,\n fileSize\n },\n binary: item.binary\n };\n});\n\nreturn images;" | |
| }, | |
| "id": "router", | |
| "name": "Neural Router", | |
| "type": "n8n-nodes-base.code", | |
| "position": [ | |
| 450, | |
| 300 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "conditions": { | |
| "options": { | |
| "caseSensitive": false | |
| }, | |
| "conditions": [ | |
| { | |
| "id": "handwriting_path", | |
| "leftValue": "={{ $json.taskType }}", | |
| "rightValue": "handwriting_ocr", | |
| "operator": { | |
| "type": "string", | |
| "operation": "equals" | |
| } | |
| }, | |
| { | |
| "id": "diagram_path", | |
| "leftValue": "={{ $json.taskType }}", | |
| "rightValue": "diagram_analysis", | |
| "operator": { | |
| "type": "string", | |
| "operation": "equals" | |
| } | |
| }, | |
| { | |
| "id": "ui_path", | |
| "leftValue": "={{ $json.taskType }}", | |
| "rightValue": "ui_analysis", | |
| "operator": { | |
| "type": "string", | |
| "operation": "equals" | |
| } | |
| } | |
| ] | |
| }, | |
| "options": {} | |
| }, | |
| "id": "switch", | |
| "name": "Task Switch", | |
| "type": "n8n-nodes-base.switch", | |
| "position": [ | |
| 650, | |
| 300 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "method": "POST", | |
| "url": "https://api-inference.huggingface.co/models/microsoft/trocr-base-handwritten", | |
| "authentication": "genericCredentialType", | |
| "genericAuthType": "httpHeaderAuth", | |
| "sendHeaders": true, | |
| "headerParameters": { | |
| "parameters": [ | |
| { | |
| "name": "Content-Type", | |
| "value": "application/json" | |
| } | |
| ] | |
| }, | |
| "sendBody": true, | |
| "specifyBody": "json", | |
| "jsonBody": "={\n \"inputs\": \"{{ $binary.data.toString('base64') }}\"\n}", | |
| "options": {} | |
| }, | |
| "id": "ocr_analyst", | |
| "name": "OCR Handwriting (TrOCR)", | |
| "type": "n8n-nodes-base.httpRequest", | |
| "position": [ | |
| 850, | |
| 200 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "method": "POST", | |
| "url": "http://localhost:1234/v1/chat/completions", | |
| "authentication": "none", | |
| "sendHeaders": true, | |
| "headerParameters": { | |
| "parameters": [ | |
| { | |
| "name": "Content-Type", | |
| "value": "application/json" | |
| } | |
| ] | |
| }, | |
| "sendBody": true, | |
| "specifyBody": "json", | |
| "jsonBody": "={\n \"model\": \"llava-v1.6-mistral-7b\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a technical diagram analyst specializing in geometry, polyforms, and compression systems. Identify: 1) Mathematical concepts shown, 2) Geometric shapes/polyhedra types, 3) Compression techniques mentioned, 4) UI/workflow elements. Output structured JSON.\"\n },\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Analyze this diagram from {{ $json.fileName }}. Focus on polyform development, compression methods, and UI design.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"data:image/jpeg;base64,{{ $binary.data.toString('base64') }}\"\n }\n }\n ]\n }\n ],\n \"temperature\": 0.2,\n \"max_tokens\": 1500\n}", | |
| "options": {} | |
| }, | |
| "id": "diagram_analyst", | |
| "name": "Diagram Analyst (LLaVA)", | |
| "type": "n8n-nodes-base.httpRequest", | |
| "position": [ | |
| 850, | |
| 300 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "method": "POST", | |
| "url": "http://localhost:1234/v1/chat/completions", | |
| "authentication": "none", | |
| "sendHeaders": true, | |
| "headerParameters": { | |
| "parameters": [ | |
| { | |
| "name": "Content-Type", | |
| "value": "application/json" | |
| } | |
| ] | |
| }, | |
| "sendBody": true, | |
| "specifyBody": "json", | |
| "jsonBody": "={\n \"model\": \"llava-v1.6-mistral-7b\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a UI/UX analyst. Extract: 1) Interface components shown, 2) Interaction patterns, 3) Data visualization methods, 4) Success indicators mentioned, 5) User workflow steps. Output structured JSON.\"\n },\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Analyze UI design from {{ $json.fileName }}. Identify successful patterns for polyform visualization and user interaction.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"data:image/jpeg;base64,{{ $binary.data.toString('base64') }}\"\n }\n }\n ]\n }\n ],\n \"temperature\": 0.3,\n \"max_tokens\": 1200\n}", | |
| "options": {} | |
| }, | |
| "id": "ui_analyst", | |
| "name": "UI Analyst (LLaVA)", | |
| "type": "n8n-nodes-base.httpRequest", | |
| "position": [ | |
| 850, | |
| 400 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "mode": "mergeByPosition", | |
| "options": {} | |
| }, | |
| "id": "merge", | |
| "name": "Merge Analysis", | |
| "type": "n8n-nodes-base.merge", | |
| "position": [ | |
| 1050, | |
| 300 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "jsCode": "// SYNTHESIS: Parse vision model responses and structure results\nconst results = items.map(item => {\n let analysis = {};\n \n try {\n // Handle TrOCR response (array format)\n if (Array.isArray(item.json)) {\n analysis = {\n extracted_text: item.json[0]?.generated_text || item.json.toString(),\n confidence: item.json[0]?.score || 0.8\n };\n }\n // Handle LLaVA response (OpenAI format)\n else if (item.json.choices) {\n const content = item.json.choices[0]?.message?.content || '{}';\n analysis = JSON.parse(content);\n }\n // Handle direct JSON response\n else if (typeof item.json === 'object') {\n analysis = item.json;\n }\n else {\n analysis = { raw_response: JSON.stringify(item.json) };\n }\n } catch (e) {\n analysis = {\n raw_response: JSON.stringify(item.json),\n parse_error: true,\n error_detail: e.message\n };\n }\n \n return {\n json: {\n file: item.json.fileName || 'unknown',\n taskType: item.json.taskType,\n analysis,\n timestamp: new Date().toISOString()\n }\n };\n});\n\nreturn results;" | |
| }, | |
| "id": "synthesizer", | |
| "name": "Synthesizer", | |
| "type": "n8n-nodes-base.code", | |
| "position": [ | |
| 1250, | |
| 300 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "method": "POST", | |
| "url": "http://localhost:1234/v1/chat/completions", | |
| "authentication": "none", | |
| "sendHeaders": true, | |
| "headerParameters": { | |
| "parameters": [ | |
| { | |
| "name": "Content-Type", | |
| "value": "application/json" | |
| } | |
| ] | |
| }, | |
| "sendBody": true, | |
| "specifyBody": "json", | |
| "jsonBody": "={\n \"model\": \"nvidia/nemotron-3-nano\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are the RESEARCH SYNTHESIZER for a polyform compression project. Analyze handwritten notes and diagrams to extract: 1) POLYFORM TYPES (Platonic, Archimedean, Johnson, near-miss solids, geodesics), 2) COMPRESSION METHODS (vertex encoding, edge compression, spheroid nets), 3) SUCCESSFUL UI PATTERNS from iterations, 4) MATHEMATICAL INSIGHTS (topology, manifolds, optimization), 5) CRITICAL GAPS to address. Output: Executive Summary, Key Findings by Category, Priority Next Steps, Integration Opportunities.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Synthesize these image analyses from research notes:\\n\\n{{ JSON.stringify($json) }}\\n\\nFocus on actionable insights for building the polyform generator and compression library.\"\n }\n ],\n \"temperature\": 0.3,\n \"max_tokens\": 3000\n}", | |
| "options": {} | |
| }, | |
| "id": "jury", | |
| "name": "Jury Consensus (Nemotron)", | |
| "type": "n8n-nodes-base.httpRequest", | |
| "position": [ | |
| 1450, | |
| 300 | |
| ] | |
| }, | |
| { | |
| "parameters": { | |
| "operation": "write", | |
| "fileName": "=/tmp/polyform_research_{{ DateTime.now().toFormat('yyyyMMdd_HHmmss') }}.json", | |
| "options": {} | |
| }, | |
| "id": "save_results", | |
| "name": "Save Research Synthesis", | |
| "type": "n8n-nodes-base.writeFile", | |
| "position": [ | |
| 1650, | |
| 300 | |
| ] | |
| } | |
| ], | |
| "connections": { | |
| "image_scanner": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "router", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "router": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "switch", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "switch": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "ocr_analyst", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ], | |
| [ | |
| { | |
| "node": "diagram_analyst", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ], | |
| [ | |
| { | |
| "node": "ui_analyst", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "ocr_analyst": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "merge", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "diagram_analyst": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "merge", | |
| "type": "main", | |
| "index": 1 | |
| } | |
| ] | |
| ] | |
| }, | |
| "ui_analyst": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "merge", | |
| "type": "main", | |
| "index": 2 | |
| } | |
| ] | |
| ] | |
| }, | |
| "merge": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "synthesizer", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "synthesizer": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "jury", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "jury": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "save_results", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| } | |
| }, | |
| "settings": { | |
| "executionOrder": "v1" | |
| } | |
| } |