8
n8n 한국어amn8n.com

동적 LLM 템플릿 전환

고급

이것은Engineering, Building Blocks, AI분야의자동화 워크플로우로, 22개의 노드를 포함합니다.주로 If, Set, Code, ChainLlm, ChatTrigger 등의 노드를 사용하며인공지능 기술을 결합하여 스마트 자동화를 구현합니다. LangChain 코드를 사용하여 AI 대리자 간 동적 LLM 전환

사전 요구사항
  • OpenAI API Key
워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
  "id": "dQC8kExvbCrovWf0",
  "meta": {
    "instanceId": "fb8bc2e315f7f03c97140b30aa454a27bc7883a19000fa1da6e6b571bf56ad6d",
    "templateCredsSetupCompleted": true
  },
  "name": "Dynamically switch between LLMs Template",
  "tags": [],
  "nodes": [
    {
      "id": "962c4b29-c244-4d68-93e1-cacd41b436fc",
      "name": "채팅 메시지 수신 시",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        220,
        80
      ],
      "webhookId": "713a7f98-0e3d-4eb7-aafa-599ca627c8b4",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "6fc4f336-09e3-4e79-94e9-e5eff04e4089",
      "name": "모델 전환",
      "type": "@n8n/n8n-nodes-langchain.code",
      "position": [
        540,
        320
      ],
      "parameters": {
        "code": {
          "supplyData": {
            "code": "let llms = await this.getInputConnectionData('ai_languageModel', 0);\nllms.reverse(); // reverse array, so the order matches the UI elements\n\nconst llm_index = $input.item.json.llm_index;\nif (!Number.isInteger(llm_index)) {\n  console.log(\"'llm_index' is udefined or not a valid integer\");\n  throw new Error(\"'llm_index' is udefined or not a valid integer\");\n}\n\nif(typeof llms[llm_index] === 'undefined') {\n  console.log(`No LLM found with index ${llm_index}`);\n  throw new Error(`No LLM found with index ${llm_index}`);\n}\n\nreturn llms[llm_index];"
          }
        },
        "inputs": {
          "input": [
            {
              "type": "ai_languageModel",
              "required": true
            }
          ]
        },
        "outputs": {
          "output": [
            {
              "type": "ai_languageModel"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "68511483-355b-45c1-915f-e7517c42b809",
      "name": "LLM 인덱스 설정",
      "type": "n8n-nodes-base.set",
      "position": [
        440,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "24b4d30e-484a-4cc1-a691-0653ed764296",
              "name": "llm_index",
              "type": "number",
              "value": "={{ $json.llm_index || 0 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "adc2f24c-0ad6-4057-bb3b-b46563c72ee8",
      "name": "LLM 인덱스 증가",
      "type": "n8n-nodes-base.set",
      "position": [
        1420,
        -200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "24b4d30e-484a-4cc1-a691-0653ed764296",
              "name": "llm_index",
              "type": "number",
              "value": "={{ $('Set LLM index').item.json.llm_index + 1 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "eace2dd7-9550-47ba-a4c3-4f065f80757b",
      "name": "작업 없음, 아무 동작 안 함",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1640,
        540
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c1735d1c-5dc4-4bd5-9dde-3bb04b8811c3",
      "name": "예상 오류 확인",
      "type": "n8n-nodes-base.if",
      "position": [
        1040,
        160
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3253e1f2-172e-4af4-a492-3b9c6e9e4797",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.error }}",
              "rightValue": "Error in sub-node Switch Model"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4a259078-aa74-4725-9e91-d2775bbd577f",
      "name": "결과 없이 루프 종료",
      "type": "n8n-nodes-base.set",
      "position": [
        1260,
        60
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b352627d-d692-47f8-8f8c-885b68073843",
              "name": "output",
              "type": "string",
              "value": "The loop finished without a satisfying result"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3b527ed3-a700-403d-8e3c-d0d55a83c9ea",
      "name": "예상치 못한 오류",
      "type": "n8n-nodes-base.set",
      "position": [
        1260,
        260
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b352627d-d692-47f8-8f8c-885b68073843",
              "name": "output",
              "type": "string",
              "value": "An unexpected error happened"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2a48a244-25ab-4330-9e89-3f8a52b7fd0a",
      "name": "결과 반환",
      "type": "n8n-nodes-base.set",
      "position": [
        1420,
        -460
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b352627d-d692-47f8-8f8c-885b68073843",
              "name": "output",
              "type": "string",
              "value": "={{ $json.text || $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "79da2795-800a-423d-ad5b-ec3b0498a5e6",
      "name": "OpenAI 4o-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        460,
        580
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "X7Jf0zECd3IkQdSw",
          "name": "OpenAi (octionicsolutions)"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c5884632-4f21-4e1e-a86d-77e3b18119b9",
      "name": "OpenAI 4o",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        640,
        580
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "X7Jf0zECd3IkQdSw",
          "name": "OpenAi (octionicsolutions)"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0693ac6a-fd1e-4a1f-b7be-bd4a1021b6c1",
      "name": "OpenAI o1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        820,
        580
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "o1",
          "cachedResultName": "o1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "X7Jf0zECd3IkQdSw",
          "name": "OpenAi (octionicsolutions)"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f9fa467a-804d-4abf-84e3-06a88f9142b4",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1100,
        -100
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "X7Jf0zECd3IkQdSw",
          "name": "OpenAi (octionicsolutions)"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7c6bf364-1844-484f-8a1c-1ff87286c686",
      "name": "응답 검증",
      "type": "@n8n/n8n-nodes-langchain.sentimentAnalysis",
      "position": [
        1040,
        -300
      ],
      "parameters": {
        "options": {
          "categories": "pass, fail",
          "systemPromptTemplate": "You are a highly intelligent and accurate sentiment analyzer. Analyze the sentiment of the provided text. Categorize it into one of the following: {categories}. Use the provided formatting instructions. Only output the JSON.\n\n> Evaluate the following customer support response. Give a short JSON answer with a field “quality”: “pass” or “fail”. Only return “pass” if the response:\n\n1. Acknowledges both the broken keyboard and the late delivery  \n2. Uses a polite and empathetic tone  \n3. Offers a clear resolution or next step (like refund, replacement, or contact support)"
        },
        "inputText": "={{ $json.text }}"
      },
      "typeVersion": 1
    },
    {
      "id": "a7be0179-e246-4f75-8863-d03eefe9d8ac",
      "name": "응답 생성",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "onError": "continueErrorOutput",
      "position": [
        660,
        80
      ],
      "parameters": {
        "text": "={{ $('When chat message received').item.json.chatInput }}",
        "messages": {
          "messageValues": [
            {
              "message": "=You’re an AI assistant replying to a customer who is upset about a faulty product and late delivery. The customer uses sarcasm and is vague. Write a short, polite response, offering help."
            }
          ]
        },
        "promptType": "define"
      },
      "retryOnFail": false,
      "typeVersion": 1.6
    },
    {
      "id": "273f4025-2aeb-4a67-859a-690a3a086f82",
      "name": "스티커 메모",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -160
      ],
      "parameters": {
        "width": 480,
        "height": 140,
        "content": "### Customer complaint - example\n\nI really *love* waiting two weeks just to get a keyboard that doesn’t even work. Great job. Any chance I could actually use the thing I paid for sometime this month?"
      },
      "typeVersion": 1
    },
    {
      "id": "a7806fab-fdc2-4feb-be53-fcea81ede105",
      "name": "스티커 메모1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 220,
        "height": 240,
        "content": "Defines the LLM node by index which should be used."
      },
      "typeVersion": 1
    },
    {
      "id": "0117d8d8-672e-458a-a9dd-30b50e05f343",
      "name": "스티커 메모2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 200,
        "content": "Dynamically connects the LLM by the index provided in the previous node."
      },
      "typeVersion": 1
    },
    {
      "id": "66066bad-4fd3-4e68-88bb-0b95fd9a6e49",
      "name": "스티커 메모3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        980,
        60
      ],
      "parameters": {
        "color": 7,
        "width": 220,
        "height": 260,
        "content": "Check if LangChain Code Node ran into error. _Currently only supports error output from main Node_"
      },
      "typeVersion": 1
    },
    {
      "id": "b9101226-0035-4de3-8720-f783d13e0cca",
      "name": "스티커 메모4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 240,
        "content": "Generates a polite answer based on the customers complaint."
      },
      "typeVersion": 1
    },
    {
      "id": "ee7d70ee-2eb7-494f-ad74-2cb6108ba0ed",
      "name": "스티커 메모5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        980,
        -360
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 220,
        "content": "Analyses the generated answer by certain criteria"
      },
      "typeVersion": 1
    },
    {
      "id": "03bde6f5-27b1-4568-96fb-5ece77d7b2e5",
      "name": "스티커 메모6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        -280
      ],
      "parameters": {
        "color": 7,
        "width": 220,
        "height": 240,
        "content": "Increases the index to choose the next available LLM on the next run"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "52381ffc-bdf4-4243-bc35-462dedb929bd",
  "connections": {
    "c5884632-4f21-4e1e-a86d-77e3b18119b9": {
      "ai_languageModel": [
        [
          {
            "node": "6fc4f336-09e3-4e79-94e9-e5eff04e4089",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "0693ac6a-fd1e-4a1f-b7be-bd4a1021b6c1": {
      "ai_languageModel": [
        [
          {
            "node": "6fc4f336-09e3-4e79-94e9-e5eff04e4089",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "6fc4f336-09e3-4e79-94e9-e5eff04e4089": {
      "ai_outputParser": [
        []
      ],
      "ai_languageModel": [
        [
          {
            "node": "a7be0179-e246-4f75-8863-d03eefe9d8ac",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "68511483-355b-45c1-915f-e7517c42b809": {
      "main": [
        [
          {
            "node": "a7be0179-e246-4f75-8863-d03eefe9d8ac",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "79da2795-800a-423d-ad5b-ec3b0498a5e6": {
      "ai_languageModel": [
        [
          {
            "node": "6fc4f336-09e3-4e79-94e9-e5eff04e4089",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "a7be0179-e246-4f75-8863-d03eefe9d8ac": {
      "main": [
        [
          {
            "node": "7c6bf364-1844-484f-8a1c-1ff87286c686",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "c1735d1c-5dc4-4bd5-9dde-3bb04b8811c3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f9fa467a-804d-4abf-84e3-06a88f9142b4": {
      "ai_languageModel": [
        [
          {
            "node": "7c6bf364-1844-484f-8a1c-1ff87286c686",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "7c6bf364-1844-484f-8a1c-1ff87286c686": {
      "main": [
        [
          {
            "node": "2a48a244-25ab-4330-9e89-3f8a52b7fd0a",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "adc2f24c-0ad6-4057-bb3b-b46563c72ee8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "adc2f24c-0ad6-4057-bb3b-b46563c72ee8": {
      "main": [
        [
          {
            "node": "eace2dd7-9550-47ba-a4c3-4f065f80757b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c1735d1c-5dc4-4bd5-9dde-3bb04b8811c3": {
      "main": [
        [
          {
            "node": "4a259078-aa74-4725-9e91-d2775bbd577f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "3b527ed3-a700-403d-8e3c-d0d55a83c9ea",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "eace2dd7-9550-47ba-a4c3-4f065f80757b": {
      "main": [
        [
          {
            "node": "68511483-355b-45c1-915f-e7517c42b809",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "962c4b29-c244-4d68-93e1-cacd41b436fc": {
      "main": [
        [
          {
            "node": "68511483-355b-45c1-915f-e7517c42b809",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
자주 묻는 질문

이 워크플로우를 어떻게 사용하나요?

위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.

이 워크플로우는 어떤 시나리오에 적합한가요?

고급 - 엔지니어링, 빌딩 블록, 인공지능

유료인가요?

이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.

워크플로우 정보
난이도
고급
노드 수22
카테고리3
노드 유형9
난이도 설명

고급 사용자를 위한 16+개 노드의 복잡한 워크플로우

저자

Workflow Optimization Expert | Software Architect. Use my link to book an initial consultation for custom built workflows using n8n.

외부 링크
n8n.io에서 보기

이 워크플로우 공유

카테고리

카테고리: 34