{"createdAt":"2024-03-25T13:03:37.504Z","updatedAt":"2024-06-18T13:48:07.270Z","id":"0idgEKY5p1q5WS9F","name":"Gitea auto AI Groq","active":true,"nodes":[{"parameters":{"model":"llama3-70b-8192","options":{"maxTokensToSample":4096},"requestOptions":{}},"id":"3c89da25-c3b5-4c0c-b82d-1b908c20a455","name":"Groq Chat Model","type":"@n8n/n8n-nodes-langchain.lmChatGroq","typeVersion":1,"position":[940,400],"credentials":{"groqApi":{"id":"u4SobGEjjuXQixeQ","name":"Groq account"}}},{"parameters":{"command":"rm -rf /tmp/repo"},"id":"40c1fc75-6aec-4bd2-8056-af814e02af60","name":"Execute Command","type":"n8n-nodes-base.executeCommand","typeVersion":1,"position":[40,-160],"notesInFlow":true,"notes":"Suppression /tmp/repo "},{"parameters":{"authentication":"gitPassword","operation":"clone","repositoryPath":"/tmp/repo","sourceRepository":"={{$node[\"Webhook\"].json[\"body\"][\"repository\"][\"html_url\"]}}"},"id":"42558044-243a-49a8-b247-e2fb13d3e828","name":"Git","type":"n8n-nodes-base.git","typeVersion":1,"position":[240,-160],"alwaysOutputData":true,"notesInFlow":true,"credentials":{"gitPassword":{"id":"7JHhvGSTGUGgQb6S","name":"gitea.ia86.cc account"}},"onError":"continueRegularOutput","notes":"Clonage repo dans /tmp/repo"},{"parameters":{"command":"ls /tmp/repo"},"id":"40130976-207a-474b-8817-bbbe6b90272e","name":"Execute Command1","type":"n8n-nodes-base.executeCommand","typeVersion":1,"position":[1280,-240],"alwaysOutputData":true,"notesInFlow":true,"notes":"Lister fichiers Git"},{"parameters":{"options":{"reset":false}},"id":"c942acf6-6861-4563-868e-704b9e6ffd0b","name":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","typeVersion":3,"position":[140,120],"notesInFlow":true,"notes":"Traite fichier par fichier"},{"parameters":{"fileSelector":"=/tmp/repo/{{$json[\"fileName\"]}}","options":{}},"id":"076ba28c-951b-40fc-b8e5-b057f0c2f610","name":"Read/Write Files from Disk","type":"n8n-nodes-base.readWriteFile","typeVersion":1,"position":[360,200],"notesInFlow":true,"notes":"Lit le fichier"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"1b92e512-49fc-47c9-a93e-b80bc1d48f3b","leftValue":"={{ $items(\"Set2\")[0].json.filtre }}","rightValue":"=.{{ $json[\"fileExtension\"] }}|","operator":{"type":"string","operation":"contains"}}],"combinator":"and"},"options":{}},"id":"cedf5e54-d0dd-42bc-bdfe-736789d061c5","name":"If","type":"n8n-nodes-base.if","typeVersion":2,"position":[560,200],"notesInFlow":true,"notes":"Extension à traiter ?"},{"parameters":{"fromEmail":"nico@ia86.cc","toEmail":"={{$node[\"Webhook\"].json[\"body\"][\"commits\"][0][\"author\"][\"email\"]}}","subject":"[IA-Gitea] Code introspection","html":"=

Consigne

\n{{ $items(\"Set2\")[0].json.consigne }}\n

Filtre

\n{{ $items(\"Set2\")[0].json.filtre }}\n

Résultat

\n{{ $node[\"Set\"].json[\"concatenatedResults\"] }}\n","options":{"replyTo":"noreply@n8n.ia86.cc"}},"id":"18637207-8730-4db8-bc96-0d661ae5078e","name":"Send Email","type":"n8n-nodes-base.emailSend","typeVersion":2.1,"position":[560,40],"notesInFlow":true,"credentials":{"smtp":{"id":"d4ZAN48vF9GTpVON","name":"SMTP account"}},"notes":"Courriel avec Variable"},{"parameters":{"httpMethod":"POST","path":"ac8544e6-b735-43c9-9d7b-dfa201f36008","options":{}},"id":"dafe642f-c21d-4b26-a17e-d93aae1320d6","name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":1.1,"position":[-160,-160],"webhookId":"ac8544e6-b735-43c9-9d7b-dfa201f36008","notesInFlow":true,"notes":"Webhook Gitea sur commit "},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"e182d1f3-0b86-4a38-951e-4eac8bfd025c","leftValue":"={{$node[\"Webhook\"].json[\"body\"][\"commits\"][0][\"message\"]}}","rightValue":"@inspectALL","operator":{"type":"string","operation":"contains"}}],"combinator":"and"},"options":{}},"id":"6395bddc-6989-4bfa-8a92-8847a3c75ad4","name":"If1","type":"n8n-nodes-base.if","typeVersion":2,"position":[1040,-160],"notesInFlow":true,"notes":"commit msg =~ @inspectALL"},{"parameters":{"command":"=cd /tmp/repo && git diff-tree --no-commit-id --name-only {{$node[\"Webhook\"].json[\"body\"][\"commits\"][0][\"id\"] }} -r"},"id":"d09ec861-52d6-4ccf-9e64-c5f53b439563","name":"Execute Command2","type":"n8n-nodes-base.executeCommand","typeVersion":1,"position":[1280,-80],"alwaysOutputData":true,"notesInFlow":true,"notes":"Lister fichiers Git modifiés"},{"parameters":{"jsCode":"const previousResults = $items(\"Set\")[0].json.concatenatedResults;\n\nconst currentResult = $json[\"text\"];\n\nconst updatedResults = previousResults + \"

\" + $items(\"Code1\")[0].json.filename + \"

\" + currentResult + \"
\";\n\nreturn [\n {\n json: {\n concatenatedResults: updatedResults\n }\n }\n];"},"id":"0b4d3c64-ab4d-45d2-abd6-b314cc9bc666","name":"Code2","type":"n8n-nodes-base.code","typeVersion":2,"position":[1280,200],"notesInFlow":true,"notes":"Concatène résultat Variable"},{"parameters":{"assignments":{"assignments":[{"id":"085cb216-3d10-4001-b426-671666827470","name":"consigne","value":"={{ $json[\"consigne\"] }}","type":"string"},{"id":"ce95566b-edbd-4da2-8325-f3426dce8dd8","name":"filtre","value":"={{ $json[\"filtre\"] }}","type":"string"}]},"options":{}},"id":"d0b0731e-6d47-4eb9-b7aa-a761406dd0fc","name":"Set2","type":"n8n-nodes-base.set","typeVersion":3.3,"position":[840,-160],"notesInFlow":true,"notes":"Consigne à \"\""},{"parameters":{"fileSelector":"/tmp/repo/.iacicd","options":{"dataPropertyName":"consigne"}},"id":"1779d890-0446-49f4-a1af-9cc57e8b8d95","name":"Read/Write Files from Disk1","type":"n8n-nodes-base.readWriteFile","typeVersion":1,"position":[440,-160],"notesInFlow":true,"alwaysOutputData":true,"onError":"continueRegularOutput","notes":"Lit le fichier ~/.iacicd"},{"parameters":{"jsCode":"const fileList = $json[\"stdout\"].split('\\n').filter(file => file !== '');\nreturn fileList.map(file => ({ json: { fileName: file } }));"},"id":"d2900ffd-edd6-4d36-930d-41814cd3f39c","name":"Code","type":"n8n-nodes-base.code","typeVersion":2,"position":[1460,-160],"notesInFlow":true,"notes":"Conversion liste fichier JSON"},{"parameters":{"jsCode":"let binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(0, 'data');\nvar data = binaryDataBufferItem.toString('utf8')\n\nreturn {\"data\": data, \"filename\" : $json[\"fileName\"] };"},"id":"e916fa11-85e7-40be-bd16-72552c7a56e4","name":"Code1","type":"n8n-nodes-base.code","typeVersion":2,"position":[760,200],"notesInFlow":true,"notes":"Transforme en JSON"},{"parameters":{"jsCode":"let binaryDataBufferItem;\nlet data;\nlet consigne;\nlet filtre;\n\ntry {\n binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(0, 'consigne');\n data = binaryDataBufferItem.toString('utf8');\n\n // Parse the YAML content manually (simple implementation)\n const lines = data.split('\\n');\n const parsedContent = {};\n\n lines.forEach(line => {\n const [key, value] = line.split(':').map(item => item.trim());\n if (key && value !== undefined) {\n parsedContent[key] = value;\n }\n });\n\n // Extract the parameters \"consigne\" and \"filtre\"\n consigne = parsedContent.consigne;\n filtre = parsedContent.filtre;\n\n return {\n json: {\n consigne: consigne,\n filtre: filtre,\n }\n };\n} catch (error) {\n return {\n json: {\n consigne: \"Analyze the following program file writed in C language. Make a summary with severals sections for 'Objectif du code', 'Sécurite du code', 'Optimisation du code' and 'Erreurs dans le code'. Max 250 words in French for each section given before. Format the resulting document in HTML format and begin with the h3 for the sections. Use table and rich HTML content if needed to ensure best document quality. No return to line but br tag or table\",\n filtre: \".c|.h|\" // or a default value for filtre if needed\n }\n };\n}"},"id":"b37f8eee-caa7-4623-8011-5e041d414bd8","name":"Code3","type":"n8n-nodes-base.code","typeVersion":2,"position":[640,-160],"notesInFlow":true,"notes":"Consigne vers JSON ou défaut"},{"parameters":{"jsCode":" return {\n json: {\n concatenatedResults: \"\"\n }\n };"},"id":"b4b24a16-4c87-41a4-9d11-bf4f0a3a0e63","name":"Code4","type":"n8n-nodes-base.code","typeVersion":2,"position":[1660,-200],"notesInFlow":true,"notes":"Entête courriel"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict"},"conditions":[{"id":"6233a192-63ca-4478-b89e-21c580889d91","leftValue":"={{$json[\"concatenatedResults\"]}}","rightValue":"","operator":{"type":"string","operation":"empty","singleValue":true}}],"combinator":"and"},"options":{}},"id":"fd9cf22c-a68e-44e3-a16c-72172340f03c","name":"If2","type":"n8n-nodes-base.if","typeVersion":2,"position":[1640,200]},{"parameters":{"assignments":{"assignments":[{"id":"7b1033bd-f129-479d-952e-9971cf9bc59b","name":"concatenatedResults","value":"={{$json[\"concatenatedResults\"]}}","type":"string"}]},"options":{}},"id":"d1c75bdf-8270-4ef0-879b-2eb318b113bb","name":"Set","type":"n8n-nodes-base.set","typeVersion":3.3,"position":[1460,200],"notesInFlow":true,"notes":"Mise à jour Variable"},{"parameters":{"keep":"lastItems"},"id":"a481165e-9ed1-4679-af23-13696071b738","name":"Limit","type":"n8n-nodes-base.limit","typeVersion":1,"position":[360,40]},{"parameters":{"promptType":"define","text":"={{ $items(\"Set2\")[0].json.consigne }}\nThe informations to treat begins after the ::: chars\nName of the file to inspect: {{ $json[\"filename\"] }} \n:::{{ $json[\"data\"] }}"},"id":"bd126cea-54d8-4842-b981-3daeb9b532be","name":"Basic LLM Chain","type":"@n8n/n8n-nodes-langchain.chainLlm","typeVersion":1.4,"position":[940,200],"notesInFlow":true,"notes":"Traitement par IA Groq"}],"connections":{"Groq Chat Model":{"ai_languageModel":[[{"node":"Basic LLM Chain","type":"ai_languageModel","index":0}]]},"Execute Command":{"main":[[{"node":"Git","type":"main","index":0}]]},"Git":{"main":[[{"node":"Read/Write Files from Disk1","type":"main","index":0}]]},"Execute Command1":{"main":[[{"node":"Code","type":"main","index":0}]]},"Loop Over Items":{"main":[[{"node":"Limit","type":"main","index":0}],[{"node":"Read/Write Files from Disk","type":"main","index":0}]]},"Read/Write Files from Disk":{"main":[[{"node":"If","type":"main","index":0}]]},"If":{"main":[[{"node":"Code1","type":"main","index":0}],[{"node":"Loop Over Items","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Execute Command","type":"main","index":0}]]},"If1":{"main":[[{"node":"Execute Command1","type":"main","index":0}],[{"node":"Execute Command2","type":"main","index":0}]]},"Execute Command2":{"main":[[{"node":"Code","type":"main","index":0}]]},"Code2":{"main":[[{"node":"Set","type":"main","index":0}]]},"Set2":{"main":[[{"node":"If1","type":"main","index":0}]]},"Read/Write Files from Disk1":{"main":[[{"node":"Code3","type":"main","index":0}]]},"Code1":{"main":[[{"node":"Basic LLM Chain","type":"main","index":0}]]},"Code3":{"main":[[{"node":"Set2","type":"main","index":0}]]},"Code4":{"main":[[{"node":"Set","type":"main","index":0}]]},"If2":{"main":[[],[{"node":"Loop Over Items","type":"main","index":0}]]},"Set":{"main":[[{"node":"If2","type":"main","index":0}]]},"Limit":{"main":[[{"node":"Send Email","type":"main","index":0}]]},"Code":{"main":[[{"node":"Code4","type":"main","index":0},{"node":"Loop Over Items","type":"main","index":0}]]},"Basic LLM Chain":{"main":[[{"node":"Code2","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":{"templateCredsSetupCompleted":true},"pinData":{},"versionId":"93b45180-0ae3-4d94-a045-50411a974460","triggerCount":1,"tags":[{"createdAt":"2024-06-14T12:54:42.473Z","updatedAt":"2024-06-14T12:54:42.473Z","id":"j3NvJA0nPKgvNQmu","name":"gitea"},{"createdAt":"2024-06-14T12:54:50.649Z","updatedAt":"2024-06-14T12:54:50.649Z","id":"3C6S1rdGCEOm4Q8g","name":"mail"}]}