8
n8n 中文网amn8n.com

HARA_E2E_工作流

高级

这是一个Engineering, AI Summarization领域的自动化工作流,包含 16 个节点。主要使用 ConvertToFile, ManualTrigger, ReadWriteFile, Agent, ExtractFromFile 等节点。 使用GPT-4自动化汽车安全分析的ISO 26262合规性

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Z59iv0jcVPieE4iB",
  "meta": {
    "instanceId": "e23a10c38a84aff056a546290ab44e4d0883223400a2378b1f2a9dd2f5a8af2a",
    "templateCredsSetupCompleted": true
  },
  "name": "HARA_E2E_工作流",
  "tags": [
    "safety",
    "ISO26262",
    "AI"
  ],
  "nodes": [
    {
      "id": "5d95ae17-a4aa-416d-9603-129e65f90f1c",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -680,
        -120
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7a74d970-30f9-4256-bba1-4dd586a7a2a5",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -120,
        -120
      ],
      "parameters": {
        "text": "=const description = {{ $json.data }}.binary.data.toString('utf-8');\\nconst prompt = `Analyze this system for hazards:\\n${description}\\n\\nOutput:\\n1. 5 potential hazards\\n2. Likely root causes\\n3. ISO 26262 relevant clauses`;\\nreturn [{ json: { prompt } }];",
        "options": {
          "systemMessage": "You are a helpful FuSA assistant"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "3682f8df-16a8-4ec5-83ee-cb99121497f3",
      "name": "AI_危害分析",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        480,
        300
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "vrJ0hwKixLk44aS4",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7ed4df13-d81e-4426-9607-de7cefaa5fb0",
      "name": "一个简单的记忆窗口",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1560,
        320
      ],
      "parameters": {
        "sessionKey": "={{ $execution.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "b8e8ff87-3675-4036-8738-31dc1e8e73b5",
      "name": "读取系统描述",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -480,
        -120
      ],
      "parameters": {
        "options": {},
        "fileSelector": "/data/inputs/1_hazard_identification/systems_description.txt"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "328cd6cc-0d09-460a-98ad-ef23f1f550ca",
      "name": "将输入转换为二进制数据",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -280,
        -120
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "b262dce7-2db9-4f54-a418-534abde45bbc",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        220,
        -120
      ],
      "parameters": {
        "options": {},
        "operation": "toText",
        "sourceProperty": "output"
      },
      "typeVersion": 1.1
    },
    {
      "id": "5359da29-26c1-492d-90ab-a8494d809e29",
      "name": "潜在风险报告.txt",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        440,
        -120
      ],
      "parameters": {
        "options": {
          "append": false
        },
        "fileName": "=/data/outputs/1_hazard_identification/Report_Hazard Identification.txt_{{ $now.toString() }}",
        "operation": "write"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "cddc0b4a-cfdf-4a62-bbe5-a80a6407657a",
      "name": "更新风险估计报告",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        1400,
        -120
      ],
      "parameters": {
        "options": {
          "append": false
        },
        "fileName": "=/data/outputs/2_risk_estimation/Report_Risk_Estimation.txt_{{ $now.toString() }}",
        "operation": "write"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "d2137c3b-003f-46b6-8b2c-0ab84fd7de52",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        860,
        -120
      ],
      "parameters": {
        "text": "=const description = \"### Hazards to Analyze:\\n\\t{{ $json.data }}\"",
        "options": {
          "systemMessage": "Act as a functional safety expert. Analyze these hazards and estimate risk per ISO 26262 (S/E/C). \\n\\tAct as a functional safety expert. Analyze these hazards and estimate risk per ISO 26262 (S/E/C):\\n\\t\\n\\t### Input Hazards:\\n\\t{Insert hazard list from file (1-5)}\\n\\t\\n\\t### Task:\\n\\t1. **Severity (S)**: Assign S0-S3 based on potential injury:\\n\\t\\t- S0: No injuries\\n\\t\\t- S1: Light-moderate injury\\n\\t\\t- S2: Severe/life-threatening injury\\n\\t\\t- S3: Fatalities\\n\\t\\n\\t2. **Exposure (E)**: Rate E0-E4 for scenario probability:\\n\\t\\t- E0: Incredibly unlikely\\n\\t\\t- E1: Very low (≤1% of operating time)\\n\\t\\t- E2: Low (≤10%)\\n\\t\\t- E3: Medium (≤50%)\\n\\t\\t- E4: High (>50%)\\n\\t\\n\\t3. **Controllability (C)**: Classify C0-C3:\\n\\t\\t- C0: Controllable by most drivers\\n\\t\\t- C1: Controllable by average drivers\\n\\t\\t- C2: Difficult to control\\n\\t\\t- C3: Uncontrollable\\n\\t\\n\\t### Output Format:\\n\\tFor each hazard, provide:\\n\\t1. [Hazard ID] | [Hazard Description]\\n\\t2. **Rating**: S[value]-E[value]-C[value]\\n\\t3. **ASIL**: QM/A/B/C/D (per ISO 26262 Table 6)\\n\\t4. **Rationale**: 1-sentence justification\\n\\t\\n\\t### Example Output:\\n\\t1. HZ-01 | False automatic braking triggered by debris\\n\\t\\t- **Rating**: S2-E3-C1\\n\\t\\t- **ASIL**: B\\n\\t\\t- **Rationale**: Sudden braking could cause rear-end collisions (S2), occurs in urban areas (E3), but drivers often regain control (C1).\\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "4db38299-87c5-45df-98bd-f91dbcec829b",
      "name": "将输入转换为二进制数据1",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        640,
        -120
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "9d303ef5-da40-485c-8d5e-4d568fcb67f9",
      "name": "转换为文件1",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1180,
        -120
      ],
      "parameters": {
        "options": {},
        "operation": "toText",
        "sourceProperty": "output"
      },
      "typeVersion": 1.1
    },
    {
      "id": "4a382915-1e35-4b40-acfd-d04a1ef4e3e2",
      "name": "风险缓解.txt",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        2320,
        -120
      ],
      "parameters": {
        "options": {
          "append": false
        },
        "fileName": "=/data/outputs/3_mitigation_strategy/Report_Risk_mitigation.txt_{{ $now.toString() }}",
        "operation": "write"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "b7a292b2-277e-4831-ad6f-ce689070e926",
      "name": "AI 代理2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1780,
        -120
      ],
      "parameters": {
        "text": "=Generate ISO 26262-compliant mitigation strategies for these ASIL-rated hazards:\\n\\n{{$json.data}}",
        "options": {
          "systemMessage": "**Role**: Functional Safety Engineer (ISO 26262 Expert)  \n**Task**: Generate technical and process mitigations for ASIL-rated hazards for each hazard.  \n**Input**: Hazard list with S/E/C ratings and ASIL classifications  \n\n---\n\n### **Rules for Mitigation Design**\n1. **ASIL-Driven Controls**:\n   - ASIL D: Mandatory hardware redundancy + SIL-4 software  \n   - ASIL C: One safety mechanism + SIL-3 software  \n   - ASIL B: Diagnostic monitoring + SIL-2  \n   - ASIL A/QM: Warning systems or procedural controls  \n\n2. **Mitigation Types**:\n   - **Technical**:  \n     - Redundancy (e.g., dual-channel sensors)  \n     - Monitoring (e.g., heartbeat checks)  \n     - Diversity (e.g., heterogeneous algorithms)  \n   - **Process**:  \n     - Testing (e.g., 100% MC/DC coverage)  \n     - Documentation (e.g., safety case evidence)  \n     - Maintenance (e.g., OTA update protocols)  \n\n3. **ISO 26262 Alignment**:  \n   - Clause 5: Hardware qualification  \n   - Clause 6: Software safety requirements  \n   - Clause 7: Verification and validation  \n\n---\n\n### **Output Format**\n```markdown\n### [Hazard ID] | [Hazard Description] (ASIL X)\n- **Technical Controls**:\n  1. [Solution 1] (ISO 26262-[Clause]-[Section])  \n     - *Rationale*: [1-sentence justification]  \n  2. [Solution 2]  \n     - *Rationale*: [1-sentence justification]  \n- **Process Controls**:  \n  - [Measure] (ISO 26262-[Clause]-[Section])  \n    - *Validation Method*: [Test/Review/Analysis]  \n\n**Traceability**: Links to [Hazard ID], [Risk Rating]  "
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "e7e2180f-9bcc-4ff3-a807-49ae2eba9ffd",
      "name": "将输入转换为二进制数据2",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        1620,
        -120
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "0be1af89-2253-4fe2-bf17-baf39b1c2730",
      "name": "转换为文件2",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        2120,
        -120
      ],
      "parameters": {
        "options": {},
        "operation": "toText",
        "sourceProperty": "output"
      },
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "fc97d1e1-986b-4181-8ae7-a3054c97d3ba",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent2": {
      "main": [
        [
          {
            "node": "Convert to File2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Potential_risks_report.txt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "Update_risk_estimation_report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File2": {
      "main": [
        [
          {
            "node": "Risks_mitigation.txt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI_Hazard_Analysis": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Agent2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Risks_mitigation.txt": {
      "main": [
        []
      ]
    },
    "A simple memory window": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          },
          {
            "node": "AI Agent2",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Read Systems_Description": {
      "main": [
        [
          {
            "node": "Convert input to binary data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Potential_risks_report.txt": {
      "main": [
        [
          {
            "node": "Convert input to binary data1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert input to binary data": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert input to binary data1": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert input to binary data2": {
      "main": [
        [
          {
            "node": "AI Agent2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update_risk_estimation_report": {
      "main": [
        [
          {
            "node": "Convert input to binary data2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Read Systems_Description",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 工程, AI 摘要总结

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量16
分类2
节点类型7
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者

A software professional with interest in building up DIY projects in embedded system software on bare-metal to POSIX compliant OS, with automation workflows on Arduinos, Raspberry Pi, STM32 controllers, ESPIf and so on

外部链接
在 n8n.io 查看

分享此工作流